Sorry, irrelevant to the point but this is the real code (accidentally omitted the elseif).
Option Explicit
Dim iim1,iret
Set iim1 = CreateObject("imacros")
iret = iim1.iimInit("",FALSE) 'connect to open iMacros browser window
Dim counter,counter2
counter = 1
counter2 = 1
Dim macro
Do While...