If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: looping problem VB

Well you did not tell us what you are really trying to do nor what problem you are having but you do not have any loop in your code so I would assume that is why there is a problem with looping or rather not looping.

Re: looping problem VB

Not sure what you mean by does not work? If the lines worked then that should work in a loop as well as it really is no different.

The only thing I see your code doing in the loop is skipping a row when the IF test is true, nothing is being done with the data so I have no idea what you are trying to do nor what problem you are experiencing.

The lines in the first post do not do anything either. They are all commented out and if the comments are removed would trigger errors as you have block IF without matching End IF

Re: looping problem VB

Do While xlRow < 500
If Not objWorksheet.Range("A" & xlRow).Value Like "678*" Then
xlRow = xlRow + 1
End If
xlRow = xlRow + 1
Loop

Your loop is not doing anything other than setting xlRow to 500 0r 501

You have to place the code to do what you want to do within the loop if you expect something to be done.

Also as coded your loop will skip a line everytime the If Statement is true as it will add in the If statement and add after the If statement so when it is true it actually adds 2 and when false it will add 1 but that is the only thing it is doing.

If your second loop xlRow has a starting value of 500 or 501 and you are incrementing that value again.

I do not normally program in Excel so I am not sure about the range statements or a couple of others you have there but that loop structure is way off.