Hi,
I'm trying to search a list for names and add totaled data for new names to another list. However, I end up adding a new row for each time I find a name that doesn't match because if the name doesn't match a row it gets added, then it checks the next row for a match and will add it again if it's not the same. I know what the problem is, but I don't know how to fix it! Any help would be appreciated.
NAdvisors is the number of rows already in the list I'm creating.
NRows is the rows in the list I'm adding data from.
With Worksheets("Reps_Capsil_Sales").Range("E1")
For j = 1 To NRows
NewRows = 0
If .Offset(j, 1) = Consultant Then
For i = 1 To NAdvisors
Counter = 0
' Find advisors who aren't on the Activity vs Sales Spreadsheet
If .Offset(j, 0) <> LastName(i) & ", " & FirstName(i) Then
NewRows = NewRows + 1
IMAdvisor = .Offset(j, 0).Value
If IsNumeric(.Offset(j, 17).Value) Then
Counter = Counter + .Offset(j, 17).Value
IMAdvisorPurch = Counter
End If
End If
Next
' Add these advisors to the new list
With Worksheets(Consultant).Range("A1")
NewRows = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
.Offset(NewRows + 1, 0).Value = IMAdvisor
.Offset(NewRows + 1, 1).Value = "0"
.Offset(NewRows + 1, 2).Value = "0"
.Offset(NewRows + 1, 3).Value = "0"
.Offset(NewRows + 1, 4).Value = "$0.00"
.Offset(NewRows + 1, 5).Value = IMAdvisorPurch
' Fit columns to cell contents
.Offset(0, 0).EntireColumn.AutoFit
.Offset(0, 1).EntireColumn.AutoFit
.Offset(0, 2).EntireColumn.AutoFit
.Offset(0, 3).EntireColumn.AutoFit
.Offset(0, 4).EntireColumn.AutoFit
.Offset(0, 5).EntireColumn.AutoFit
End With
End If
Next
End With
Bookmarks