Question : Integrate a counter variable into VBA code... how to?

How do I implement a counter inside some code so that I can test for the counter value at the end of the code?

I tried
Dim counter as integer
counter = 0

if this happens then
counter = counter + 1
else
End If

If this occurs then
counter = counter + 1
Else
End If

etc, etc,

..but it doesn't work- the counter stays at 1?

Thanks

Answer : Integrate a counter variable into VBA code... how to?

Not quite sure what you're asking, but I'll give it a shot.

Dim iCounter as Integer
iCounter = 0

If apples = oranges then
  iCounter = iCounter + 1
end if

If moon.Composition = acCheese then
  iCounter = iCounter + 1

if iCounter = 1 then
  'Do something here
else
  'Do something else.
end if

Define 'this happens' and 'this occurs' in your code.
Random Solutions  
 
programming4us programming4us