Good morning, I am building a macro that will find a certain text from cell A2 sheet named Committees withing the range of P2:CP5000 in sheet called database, and return data of column A:O in the same rows from all the rows that contain this text string, and print it out started from cell F2 on the sheet called reports. Here is what I have done based on some suggestions. However, it is not returning expected values, it copies data from column A in Database to F:T in reports. Also I think the loop is not working since it won't stop after the last row in range r1.
Sub Macro1()
Dim r1 As Range, r2 As Range, r3 As Range
Dim rw1 As Long
Dim tmpRow As Long
tmpRow = 2
Set r2 = Sheets("Committees").Range("A2")
Set r1 = Sheets("Database").Range("P2:CO5000")
Set r3 = ThisWorkbook.Sheets("Reports").Range("F2:T2")
rw1 = 0
rw1 = r1.Find(What:=r2.Value, After:=r1(1)).Row
Do While rw1 <> 0
r3.Value = Sheets("Database").Range("A" & rw1 & ":O" & rw1).Value
tmpRow = tmpRow + 1
Set r3 = ThisWorkbook.Sheets("Reports").Range("F" & tmpRow & ":T" & tmpRow)
rw1 = 0
rw1 = r1.FindNext().Row
Loop
End Sub
Thanks in advance!