Sub Get_SQnumber2()
Dim rng As Range, cell As Range
Dim lc As Integer
Dim s As String, sInput As String
lc = Cells(3, Columns.Count).End(xlToLeft).Column
Set rng = Range(Cells(3, 1), Cells(3, lc))
'Set lookup range
Set LkupRng = Sheets("Data").Range("A1").CurrentRegion
For Each cell In rng
If cell.Value Like "SQ-*" Then
MsgBox cell.Value
s = Left(cell.Value, InStr(1, cell.Value & " ", " ") - 1)
MsgBox "s: " & s
On Error Resume Next
v = WorksheetFunction.VLookup(s, LkupRng, 5, 0)
Sheets("DRA Summary").Range("F2") = v
End
End If
Next
End Sub
If it finds the SQ-*** value in column A of the 'Data' worksheet it returns the value in column E of the same row to cell F2 of the 'DRA Summary' worksheet, and then ends the procedure.
A simple way if you just want to check a value exists in the other worksheet, is:
Open in new window
Joop