VBA, repeat command

  • Thread starter Thread starter p.strijbosch
  • Start date Start date
P

p.strijbosch

Hello!

Can some one tell me how to repeat a specific command within a Macro?
My case:
In tab 1 I copy in columns of raw unsorted data
In tab 2 the raw data from tab 1 needs to be grouped and sorted
according to a custom format.

I already defined a macro that copies the raw data and puts it into the
custom format, but as the number of columns differs I was wondering if
there is a statement in VBA that repeats a command depending on the
amount of columns (ranges) that are provided.

Thanx in advance!

Regards,
Robert
 
For i = 1 to Cells(1,Columns.Count).End(xlToLeft).Column
do your stuff on Columns(i)
Next i

which will identify all the columns and loop through them one at a time.

Does this help?
 
Back
Top