I am getting the "next without for", but it is there???

jimayers

Board Regular
Joined
Nov 14, 2010
Messages
99
Hello - in the following code it is suppose to take the values in column B on activesheet one at a time and perform a search of that value on sheet (SMs), returning it and the values of neighboring cells back to active sheet. I can not get it to work as is...right now I am getting the "next without for" error, BUT I have both "for" and "next."
Code:
Sub lookUp_ALL_in_Column2()
Application.ScreenUpdating = False
Dim pFind As Range
Dim Lastrow As Long
Dim i As Integer
Dim C As Range
Lastrow = Cells(Rows.Count, "C").End(xlUp).Row
With ActiveSheet
For i = 1 To Lastrow
b:
    Set C = Cells(i, 2)
    If C <> Application.xlnull Then
    
        Set pFind = Sheets("SMs").Range("E:E").find(What:=C.Value, LookIn:=xlValues, LookAt:=xlWhole)
        If pFind Is Nothing Then
            'MsgBox ("CD#" & C & " not found on SOMs Sheet.")
            C.Offset(, -1).Interior.ColorIndex = 6
            GoTo b:
        End If
    C.Offset(0, -1).Value = pFind.Offset(0, -4)
    C.Value = pFind.Value
    C.Offset(0, 1).Value = pFind.Offset(0, 6)
Next
End If
End With

Application.ScreenUpdating = True
End Sub

Any help would be appreciated - Jim Ayers
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top