Hai, I new to VBA and would like help trying to figure out how to write this code.
It stuck at "Next i" what code should i use. Did i missing a step or using a wrong code.
Thank in advance.
Sub finddata()
'1. declare variables
'2. clear old search results
'3. find records that match criteria and paste them
Dim Source As String
Dim Month As String
Dim Year As String
Dim finalrow As Integer
Dim i As Integer 'row counter
Sheets("Master").Range("AN6:AX300").ClearContents
Source = Sheets("Master").Range("AN2").Value
Month = Sheets("Master").Range("AP2").Value
Year = Sheets("Master").Range("AQ2").Value
finalrow = Sheets("Master").Range("B10000").End(xlUp).Row
For i = 2 To finalrow
If Cells(i, 2) = Source Then
If Cells(i, 5) = Month Then
If Cells(i, 6) = Year Then
Range(Cells(i, 2), Cells(i, 12)).Copy
Range("AN100").End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulasAndNumberFormats
End If
Next i
Range("AN2").Select
Range("AP2").Select
Range("AQ2").Select
Bookmarks