Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
for next loop not working
Help! I have a For/Next loop that is working fine for the first 13 of 14 items (NumOfEndItems = 14 in this case), then instead of going to item 14, it skips from 13 to 175 and exits the loop prematurely, before item 14 can be processed... has anyone run into this or a similar problem before? For T = 1 To NumOfEndItems Call GetDaBOM(EndItem(T), AllBOMsPage, T) Next Could it be that GetDaBOM is returning something it shouldn't or maybe a problem with variables being defined globally/locally? Confused, Dante |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
for next loop not working
Something is modifying the value of 'T' outside of your For Next routine. You could try changing your GetDaBOM function declaration to pass the argumanets ByVal instead of ByRef, ie:- Public Function GetDaBOM(ByVal ThisEndItem as Object, ByVal ThisAllBOMsPage as Object, ByVal ThisT As Object) As Long 'T' could be public scoped as you say, but I guess you must have checked this already. -- Alan Moseley IT Consultancy http://www.amitc.co.uk If I have solved your problem, please click Yes below. Thanks. "dantee" wrote: Help! I have a For/Next loop that is working fine for the first 13 of 14 items (NumOfEndItems = 14 in this case), then instead of going to item 14, it skips from 13 to 175 and exits the loop prematurely, before item 14 can be processed... has anyone run into this or a similar problem before? For T = 1 To NumOfEndItems Call GetDaBOM(EndItem(T), AllBOMsPage, T) Next Could it be that GetDaBOM is returning something it shouldn't or maybe a problem with variables being defined globally/locally? Confused, Dante |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
for next loop not working
Ok. I made a dumb mistake. Sorry about that.
There is an "if" statement within the subroutine GetDaBOM that modified T in certain cases: i used the variable T within that conditional statement (and within the subroutine) to count something else besides EndItem(T) by accident. It was careless on my part. It really does help to bounce these problems off other vba users. Careless mistake or not. Thanks for extending your help. Dante -- "Alan Moseley" wrote: Something is modifying the value of 'T' outside of your For Next routine. You could try changing your GetDaBOM function declaration to pass the argumanets ByVal instead of ByRef, ie:- Public Function GetDaBOM(ByVal ThisEndItem as Object, ByVal ThisAllBOMsPage as Object, ByVal ThisT As Object) As Long 'T' could be public scoped as you say, but I guess you must have checked this already. -- Alan Moseley IT Consultancy http://www.amitc.co.uk If I have solved your problem, please click Yes below. Thanks. "dantee" wrote: Help! I have a For/Next loop that is working fine for the first 13 of 14 items (NumOfEndItems = 14 in this case), then instead of going to item 14, it skips from 13 to 175 and exits the loop prematurely, before item 14 can be processed... has anyone run into this or a similar problem before? For T = 1 To NumOfEndItems Call GetDaBOM(EndItem(T), AllBOMsPage, T) Next Could it be that GetDaBOM is returning something it shouldn't or maybe a problem with variables being defined globally/locally? Confused, Dante |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
For...Each loop not working | Excel Programming | |||
Do Until Loop Not Working | Excel Programming | |||
Loop Not Working | Excel Programming | |||
for next loop not working | Excel Programming | |||
for next loop not working | Excel Programming |