Hello there,
I am trying to write some VBA code that will loop through the first column of a sheet until the value of the cell matches the value of a variable previously stored from an inputbox. Then return the value of the cell next to it, in a message box.
I just started using VBA so I am not sure how to debug correctly, or how to find my error. Help is appreciated. Thank you.
This is what I have so far:
I am trying to write some VBA code that will loop through the first column of a sheet until the value of the cell matches the value of a variable previously stored from an inputbox. Then return the value of the cell next to it, in a message box.
I just started using VBA so I am not sure how to debug correctly, or how to find my error. Help is appreciated. Thank you.
This is what I have so far:
Code:
Public Sub SearchEngine()
'Finds the location of an engine based on a EDC number input'
Dim edc As Integer
Dim xcol As Integer
Dim xrow As Integer
xcol = 1
xrow = 1
edc = InputBox("Enter the EDC number")
Do Until Cells(xrow, xcol).Value = edc
Cells(xrow, xcol).Select
If ActiveCell.Value = edc Then
MsgBox ("Engine Model = " & ActiveCell.Offset(0, 1).Value)
Else
MsgBox ("This EDC number does not exist")
Exit Do
End If
xrow = xrow + 1
Loop
End Sub
