I have an excel macro as below
sub macro1()
Range("A1").Select #A1 cell will be selected and analysis done on that
Selection.Copy
do Action 1 on Ai cell where i is from 1 to 4
end sub
sub macro2()
do Action 2 on Ai cell where i is from 1 to 4
end sub
sub macro3()
do Action 3 on Ai cell where i is from 1 to 4
end sub
I want that all actions 1 , 2 and 3 are done from A1 to A4 sequentially. First do all steps for A1, then do all steps for A2, then do all steps for A3 and finally do everything for A4.
I want to do something like Ai Sub macro1() Dim i As Integer For i = 1 To 4 Range("Ai").Select #this syntax is wrong, but how to do Ai kind of range, so that it takes A1, does all 3actions, then A2 and so on till A4 cell Selection.Copy Next i Do Action 1 on Ai cell where i is from 1 to 4 End Sub
Sub macro2()
Do Action 2 on Ai cell where i is from 1 to 4
End Sub
Sub macro3()
Do Action 3 on Ai cell where i is from 1 to 4
End Sub
Despite having a for loop, my macro only runs for A1 cell , it does not run for A2, then A3 then A4. Please tell what could be wrong
Range("Ai").Select
would work. Variables don't belong inside quotes:Range("A" & i).Select
. But you shouldn't select anyway, see this. – BigBenFor ....
andNext
are repeated, not the statements after theNext
. – Luuk