Hi,
I need to do something on a series of accounts with a macro and I am stuck on how to use a goto statement inside a loop.
for example my codes is:
what i am trying to do here is if condition A is met, go directly to the next account and loop the whole process again. but if condition B is met, modify the account then DO NOT run the code "nextaccount" and loop the whole process again.
the weird thing is that, the exact same code works for me most of the time but sometimes it does not. why?
when i use one or two line only, it works most of the time, but when i change it to multiple lines as followed, it does not seems to work as i wanted
if use this "nextfunction" instead of "nextaccount"
can someone please help? any help is appreciated!
thanks!
I need to do something on a series of accounts with a macro and I am stuck on how to use a goto statement inside a loop.
for example my codes is:
PHP:
Excel.Range("A2").select
accountno = excel.activecell.offset(0,0)
count = 0
do until XXXX
if conditionA then goto nextaccount
if conditionB then
modify something with the account here
end if
nextaccount:
Excel.Activecell.offset(1,0).select
count = count + 1
loop
what i am trying to do here is if condition A is met, go directly to the next account and loop the whole process again. but if condition B is met, modify the account then DO NOT run the code "nextaccount" and loop the whole process again.
the weird thing is that, the exact same code works for me most of the time but sometimes it does not. why?
when i use one or two line only, it works most of the time, but when i change it to multiple lines as followed, it does not seems to work as i wanted
if use this "nextfunction" instead of "nextaccount"
PHP:
nextfunction:
do something here (as simple as sendkey "K")
do something here as well (as simple as sendkey "Enter")
also do something (as simple as sendkey "Enter")
count = count + 1
can someone please help? any help is appreciated!
thanks!