Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loops and next not working

Status
Not open for further replies.

khansen97

Programmer
Oct 14, 2003
60
US
I have some code that I am trying to get to run. Logically this is what I want it to do:

For gdprnum = 1 To 150
gdpcarline = ActiveSheet.Cells(gdprnum, 1).Value
if volumcarline = gdpcarline Then
Workbooks("NEW 04_FCST-May.xls").Activate
Worksheets("Volume Summary by PCBS").Activate
xcorrect = ActiveSheet.Cells(forrnum, cnum).Value
exit for
Else
Next gdprnum
End If
Next gdprnum

However, that is not working correctly. I keep getting an error saying thatmy first next gdprnum is without a for.

any suggestions?
 
There is no reason for the else clause in your if-then statement. Remove it and you won't have this problem.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top