This code works EXCEPT when the the first row of data is what I am trying to match. Thank you!!
Sub fLocateClientInSourceData()
SourceDataRow = 5 'row to begin search on SourceData tab for client name match
DetailDataRow = 10
DetailClient = Detail.Cells(1, 1).Value 'location of client name in Detail tab
'MsgBox (DetailClient & " DetailClient")
SourceClient = SourceData.Cells(SourceDataRow, 1) 'location of cells to search in SourceData
'msgBox (SourceClient & " SourceClient")
SourceManagerName = SourceData.Cells(SourceDataRow, 2) 'location of cells to search for 'Total'
DetailManagerName = Detail.Cells(DetailDataRow, 1) 'location of cells in Detail to place Source Manager name
Do Until DetailClient = SourceClient ' loop thru until Detail client name = SourceData client name
SourceDataRow = SourceDataRow + 1 'add row until match is found
SourceClient = SourceData.Cells(SourceDataRow, 1)
If DetailClient = SourceClient Then
Do While DetailClient = SourceClient 'match occurred during Do Until step above
DetailManagerName = Detail.Cells(DetailDataRow, 1)
SourceManagerName = SourceData.Cells(SourceDataRow, 2)
DetailManagerName = SourceManagerName
If SourceManagerName <> "zzTotal" Then 'update data for all managers
Detail.Cells(DetailDataRow, 1) = DetailManagerName
Detail.Cells(DetailDataRow + 1, 2) = SourceData.Cells(SourceDataRow, 3) / 1000 'update Detail tab Shares column
ElseIf SourceManagerName = "zzTotal" Then 'update data for total row
Detail.Cells(8, 2) = SourceData.Cells(SourceDataRow, 3) / 1000 'update Detail tab Shares column
End If
DetailDataRow = DetailDataRow + 3 'move to next row in Detail tab for pasting data
SourceDataRow = SourceDataRow + 1 'move to next row in SourceData tabfor retrieving data
SourceClient = SourceData.Cells(SourceDataRow, 1)
Loop
End If
If IsEmpty(SourceData.Cells(SourceDataRow, 1)) Then Exit Do
Loop
End Sub
Sub fLocateClientInSourceData()
SourceDataRow = 5 'row to begin search on SourceData tab for client name match
DetailDataRow = 10
DetailClient = Detail.Cells(1, 1).Value 'location of client name in Detail tab
'MsgBox (DetailClient & " DetailClient")
SourceClient = SourceData.Cells(SourceDataRow, 1) 'location of cells to search in SourceData
'msgBox (SourceClient & " SourceClient")
SourceManagerName = SourceData.Cells(SourceDataRow, 2) 'location of cells to search for 'Total'
DetailManagerName = Detail.Cells(DetailDataRow, 1) 'location of cells in Detail to place Source Manager name
Do Until DetailClient = SourceClient ' loop thru until Detail client name = SourceData client name
SourceDataRow = SourceDataRow + 1 'add row until match is found
SourceClient = SourceData.Cells(SourceDataRow, 1)
If DetailClient = SourceClient Then
Do While DetailClient = SourceClient 'match occurred during Do Until step above
DetailManagerName = Detail.Cells(DetailDataRow, 1)
SourceManagerName = SourceData.Cells(SourceDataRow, 2)
DetailManagerName = SourceManagerName
If SourceManagerName <> "zzTotal" Then 'update data for all managers
Detail.Cells(DetailDataRow, 1) = DetailManagerName
Detail.Cells(DetailDataRow + 1, 2) = SourceData.Cells(SourceDataRow, 3) / 1000 'update Detail tab Shares column
ElseIf SourceManagerName = "zzTotal" Then 'update data for total row
Detail.Cells(8, 2) = SourceData.Cells(SourceDataRow, 3) / 1000 'update Detail tab Shares column
End If
DetailDataRow = DetailDataRow + 3 'move to next row in Detail tab for pasting data
SourceDataRow = SourceDataRow + 1 'move to next row in SourceData tabfor retrieving data
SourceClient = SourceData.Cells(SourceDataRow, 1)
Loop
End If
If IsEmpty(SourceData.Cells(SourceDataRow, 1)) Then Exit Do
Loop
End Sub