I have the start of some VBA which is almost there.
I want to get along the first row and find a word in a number of columns, "Fund". If the cell contains "Fund", to then go down the column to whatever cells contain "1" and pull through data +1 and +5 cells away in the same row.
It works for unique column names, if i change for example the code to Fund1 and cell Q1 to Fund1 it works. But not for more than one cells containing "Fund".
I need to set up some kind of loop so that it carries on finding the word "Fund" after it completed the first time it sees it.
Sub consolidate()
Dim FindRow As Range
Dim rowloc As Integer
Dim c As Object
Dim fundrow As Integer
Dim count As Integer
count = 1
fundrow = 1
Dim isin As String
Dim weight As String
Set Sht = ActiveWorkbook.Worksheets("LM Holdings")
Sht.Range("A:B").ClearContents
Sht.Activate
Set c = Sht.Rows(1).Find(What:="Fund", LookIn:=xlValues)
If Not c Is Nothing Then
Set FindRow = Sht.Rows(1).Find(What:="Fund", LookIn:=xlValues)
rowloc = FindRow.Column
Do Until count = 10
If Cells(count, rowloc).Value = "1" Then
isin = Cells(count, rowloc + 1).Value
weight = Cells(count, rowloc + 5).Value
Sht.Activate
Cells(fundrow, 1).Value = isin
Cells(fundrow, 2).Value = weight
fundrow = fundrow + 1
End If
count = count + 1
Loop
End If
End Sub