Hi All
I have a macro that lookup from imput sheet to match records on on sample database sheet , if record exist it will update header A1 AND B1 columns of imput sheets .
Now I will have several sheets with sample databaseAA , sample database BB and so on .
There will a criteria on imput sheet L2 so that it will lookup the appropriate sheet tabs and update accordingly .
Can anyone help to adjust
See attached
I have a macro that lookup from imput sheet to match records on on sample database sheet , if record exist it will update header A1 AND B1 columns of imput sheets .
Now I will have several sheets with sample databaseAA , sample database BB and so on .
There will a criteria on imput sheet L2 so that it will lookup the appropriate sheet tabs and update accordingly .
Can anyone help to adjust
See attached
Code:
Sub Button1_Click()
Dim SHT1 As Worksheet, SHT2 As Worksheet
Dim Rws As Long, Rng As Range, C As Range
Dim Rws1 As Long, Rng1 As Range, d As Range
Set SHT1 = Worksheets("Sample ")
Set SHT2 = Worksheets("Sample Data base ")
With SHT1
Rws = .Cells(Rows.Count, "C").End(xlUp).Row
Set Rng = .Range(.Cells(2, 3), .Cells(Rws, 3))
End With
With SHT2
Rws1 = .Cells(Rows.Count, "A").End(xlUp).Row
Set Rng1 = .Range(.Cells(2, 1), .Cells(Rws1, 1))
End With
For Each C In Rng.Cells
For Each d In Rng1.Cells
If C = d And C.Offset(0, 1) = d.Offset(0, 1) Then
C.Offset(0, -1) = d.Offset(0, 3)
C.Offset(0, -2) = d.Offset(0, 2)
End If
Next d
Next C
End Sub