hello everyone ,
I have an assigment for work and Its basically a code to check every row in a database that match three cratiria which will be defined by the user
name, month and year ,, it has to work through a huge database and then retrive the entire row , I got error in the IF line
please help
thank you in advance
I have an assigment for work and Its basically a code to check every row in a database that match three cratiria which will be defined by the user
name, month and year ,, it has to work through a huge database and then retrive the entire row , I got error in the IF line
Code:
Dim db As Worksheet
Dim inp As Worksheet
Dim i As Long
Dim lr As Long
Dim Lrow As Long
Set db = Sheets("DB")
Set inp = Sheets("Input")
Set r = db.Range("B:N")
lr = Sheets("DB").Cells(Rows.Count, "c").End(xlUp).Row + 1
i = 2
Sheets("DB").Activate
For i = 2 To lr
If inp.Cells("K11").Value = db.Cells("d" & i).Value And inp.Cells("L11").Value = db.Cells("I" & i).Value And inp.Cells("M11").Value = db.Cells("J" & i).Value Then
db.Range("B" & i & " :N" & i).Copy Sheets("rtv").Range("a" & i).pastevalues
End If
i = i + 1
Next
Lrow = Sheets("rtv").Cells(Row.Count, "a").End(xlUp).Row + 1
Sheets("rtv").Range("a2:" & Lrow).Copy inp.Cells("c15").pastevalues
please help
thank you in advance
Last edited by a moderator: