PDA

View Full Version : Go to cell based on value of another cell



NeekyBog
08-18-2015, 12:38 PM
Good afternoon,

I would like to insert a button on a spreadsheet that would look up a value on the next sheet, then find that value in column A, then go to the cell next to the one in column B, and paste specific information there. Any help to code this in VBA would be greatly appreciated.

Thanks so much,
Neeky

mancubus
08-19-2015, 02:09 PM
welcome to VBAX.

try:


Sub vbax_53513_FindInAnotherSheet()

Dim FoundRange As Range
Dim LookUpValue, ValueToPaste

LookUpValue = "MyLookUpValue"
ValueToPaste = "MyValueToPaste"

With Worksheets("Sheet2").Range("A:A") 'change next sheet name, Sheet2 in my example, to suit
Set FoundRange = .Find(LookUpValue, LookIn:=xlValues)
'for find method in detail, visit: https://msdn.microsoft.com/en-us/library/office/ff839746.aspx
If Not FoundRange Is Nothing Then
FoundRange.Offset(0, 1).Value = ValueToPaste
End If
End With

End Sub