Repeating Macros

 comsdev -

Does anyone know how to repeat a macros?

I have recorded the following command as a macro in Excel (2007), but I would like the task or `command' to occur for each row until there is no more data in the spreadsheet - does anyone know what code I would need to achieve this?

Sub CombineRows2()
' CombineRows2 Macro
' Combine Column G to Column N
' Keyboard Shortcut: Ctrl+Shift+R

End Sub

I'd be grateful for any help, Kind Regards

2 replies

Registration date
Sunday June 14, 2009
Last seen
August 7, 2021
this is a trivial macro perhaps for training purposes. it is ok. what do you want to do in the required macro . let me phrase it
first you want to select A1 to H1
then you want to select A2 to H2
like this till the last row

if this is so it can be done. But if the operation is only "to select" at one time it can select only one range. for .e.g when you select A2:H2 only this will be selected highlighted) and nothing else . any how your macro will be like this '

at the end of the macro only the last row range will be selected. what is the use of it. you can very well select the last row range manually. after selecting the range if you want to some other work then it will be useful

there should be data from A1 down with no gaps

Sub test()
Dim r As Range, c As Range
Set r = Range(Range("A1"), Range("A1").End(xlDown))
For Each c In r
Range(Cells(c.Row, "A"), Cells(c.Row, "H")).Select
Next c

End Sub
We talk about functions of Excel in our daily routine. One of the millions of functions of Excel is "Macros". When you turns the Macros "on", it starts recording whatever is being done in particular excel sheet. So you can get to know about the work done by your co workers on one Excel Sheet in your absence. Moreover, it can also be used for security purpose. In fact you can use Macros in as many ways as your imagination allows you. Complete MS Excel Macro Training material can be downloaded by clicking on the following mentioned link