Program skips for loop

ShieBoon

Board Regular
Joined
May 3, 2011
Messages
111
Hi all,

When i run my codes, my program skips the for loop and goes on to the next line after the loop. What happened??

Using excel 2003

Thanks
Shie Boon
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Alright

NextRecord = 0 ' set global variable back to 0 to solve deletion problem
For x = 1 To FinalCol
Call NextBlankVisCell(CInt(x))
Next
MsgBox (NextRecord)
Load Insert_New_Record_Form
Insert_New_Record_Form.MultiPage_Insert.Value = 0
Insert_New_Record_Form.Show

When i run the program in 'step into' mode, it skips the For loop~!
 
Upvote 0
So how does FinalCol get it's value? If FinalCol is greater than 1 then the loop is taking place.
As you step through (using F8) is the cursor jumping to the NextBalnkVisCell routine?
 
Upvote 0
Are you sure that you have set x to 1 before this section of code. If you have the locals window open whilst stepping through, you should be able to see what value x (and your other variables) are at during each step.
 
Upvote 0
Hi Jim and Steeviee, thank you for your replies and my apologies for the late reply.

To Jim: FinalCol is a global variable i've declared. It has a value of 32. Right before i posted this thread, I encountered a weird situation where the cursor skips the for loop in step mode. (Yellow Highlighted "For x = 1 To FinalCol" jumps to Yellow Highlighted "MsgBox (NextRecord)") Whereas after when i step through it again, the for loop undergoes. But i didn't change anything.

To Steeviee, I thought x = 1 to FinalCol already declares x as 1?

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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