I having a problem with trying to get a Vlookup working in VBA.
In the following code the first one works just fine (all on the same sheet) The second version tries to do exactly the same thing but retrieve data from sheet 2 (data duplicated in identical locations)
Private Sub CommandButton1_Click()
Range("B2") = Application.WorksheetFunction.VLookup(Range("A2"), Range("H1:K20"), 4, False)
End Sub
Private Sub CommandButton2_Click()
Range("Sheet1!B3") = Application.WorksheetFunction.VLookup(Range("sheet2!A3"), Range("H1:K20"), 4, False)
End Sub
I've searched the board for "VBA Vlookup" there are over 300 hits so it seems I'm not alone, I also searched Mr Excel articles normally such a rich resourse, nothing. If anyone can help thank you, or if you know of a good but simple example can you please point me in the right direction.
Many thanks
Mike
In the following code the first one works just fine (all on the same sheet) The second version tries to do exactly the same thing but retrieve data from sheet 2 (data duplicated in identical locations)
Private Sub CommandButton1_Click()
Range("B2") = Application.WorksheetFunction.VLookup(Range("A2"), Range("H1:K20"), 4, False)
End Sub
Private Sub CommandButton2_Click()
Range("Sheet1!B3") = Application.WorksheetFunction.VLookup(Range("sheet2!A3"), Range("H1:K20"), 4, False)
End Sub
I've searched the board for "VBA Vlookup" there are over 300 hits so it seems I'm not alone, I also searched Mr Excel articles normally such a rich resourse, nothing. If anyone can help thank you, or if you know of a good but simple example can you please point me in the right direction.
Many thanks
Mike