Irvin
your request is too vague to give you specific help. using Microsoft's help within Excel, can get you examples of how to use a command.
What you see below is a copy of a help page. you mentioned you were trying to use macros. for something like this you will probably have to write your macro in VBA. VBA is easy if you have done any programming or are willing to learn a few commands or statements
Do...Loop Statement Example
This example shows how Do...Loop statements can be used. The inner Do...Loop statement loops 10 times, sets the value of the flag to False, and exits prematurely using the Exit Do statement. The outer loop exits immediately upon checking the value of the flag.
Dim Check, Counter Check = True: Counter = 0 ' Initialize variables. Do ' Outer loop. Do While Counter < 20 ' Inner loop. Counter = Counter + 1 ' Increment Counter. If Counter = 10 Then ' If condition is True. Check = False ' Set value of flag to False. Exit Do ' Exit inner loop. End If Loop Loop Until Check = False ' Exit outer loop immediately.
Do...Loop Statement Example
This example shows how Do...Loop statements can be used. The inner Do...Loop statement loops 10 times, sets the value of the flag to False, and exits prematurely using the Exit Do statement. The outer loop exits immediately upon checking the value of the flag.
Dim Check, CounterCheck = True: Counter = 0 ' Initialize variables.Do ' Outer loop. Do While Counter < 20 ' Inner loop. Counter = Counter + 1 ' Increment Counter. If Counter = 10 Then ' If condition is True. Check = False ' Set value of flag to False. Exit Do ' Exit inner loop. End If LoopLoop Until Check = False ' Exit outer loop immediately.