I have confirmed that I am looking in the wrong sheet with the MsgBox statements.
The statement "For Each cell In rng" should be looking in the sheet called "DRA Summary", but the MsgBox reveals the data sheet name is "Data". I am in a loop that keeps finding the value "GQ-000" instead of advancing to the next value of "GQ-001". I believe this is because the program is looking in the wrong sheet.
Could someone verify this and tell me what I am doing wrong?
Thanks in advance for your help.
I have attached the workbook as well. The module is "Test_GQModule".
Dim rng As Range, cell As Range
Dim lc As Long
Dim s As String, x As String
lc = Cells(3, Columns.Count).End(xlToLef
Set rng = Range(Cells(3, 1), Cells(3, lc))
For Each cell In rng
If cell.Value Like "GQ-*" Then
MsgBox "Sheet Name: " & ActiveSheet.Name
s = Left(cell.Value, InStr(1, cell.Value & " ", " ") - 1)
On Error Resume Next
x = Application.VLookup(s, Worksheets("Data").Range("
A:XFD"), 5, 0)
Sheets("DRA Summary").Range("F2") = x