Problem: I have a list in Sheet1 ("Main") in Column X that is dynamic in length every time I run the program. The list will be used as the search parameter for each search until the list has ended.
I would like the program then to start with the first row in Sheet 1 Column X as the search term, ie: Morrison Maierle and then search Sheet 2 ("NoRetention") for the match throughout the sheet in column K, and each time it finds word I would like it to reference a cell that is 8 column away from it in column S.
Keep doing this for every instance of the word and then total up the amounts in Column S.
Solution: I have thought up so far a solution that does not work but I think is close to there. I have written it out to copy all cells into Column W. What I have not done is make it total up everything in Column Y and place that amount in the same row as the name it search Morrison Maierle in Column Y.
Goal: When the program is done I have a neat list of column X companies, and column Y of total amounts it found in Sheet2("NoRetention") that were added up from Column W.
Code so far:
Sub SearchForReceivedAmt()
Dim wsData As Worksheet
Dim wsDest As Worksheet
Dim rngFound As Range
Dim strFind As String
Dim strFirst As String
Dim counter As Integer
Dim pastecounter As Integer
Set wsData = Sheets("NoRetention")
Set wsDest = Sheets("Main")
pastecounter = 1
businesscounter = 1
strFind = Sheet1.Cells(businesscounter, "X").Text
wsDest.Cells(1, "X").Activate
Do Until ActiveCell Is Nothing
Set rngFound = wsData.Range("K:K").Find(What:=strFind, After:=ActiveCell, LookIn:=xlValues, Lookat:=xlPart)
If Not rngFound Is Nothing Then
ActiveCell.Offset(0, 8).Activate
ActiveCell.Copy
wsDest.Cells(pastecounter, "W").Paste
wsData.Activate
ActiveCell.Offset(0, -8).Activate
pastecounter = pastecounter + 1
businesscounter = businesscounter + 1
Else
Exit Sub
End If
Set rngFound = Nothing
Loop
wsDest.Activate
ActiveCell.Offset(1, 0).Activate
Loop
Err_handle: Exit Sub
End Sub
Also have attached a sample test book of the problem.
Bookmarks