Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro needed for inserting blank rows
I need a macro to insert a set number of rows, scroll the mouse, hit the
hotkey again and rows are inserted there. Specifically: I want to put the cursor on a row and have two new rows (blank) inserted beneath the row I have the mouse on. Just scroll the mouse to a row, click a hotkey, two new rows are inserted, scroll the mouse to a new location, hit the hotkey, two new rows inserted there--and so forth. I've tried; but my macro, every time I hit the hotkey, keeps adding row to the initial location. It is using absolute address instead of relative & I don't know how to get it to stop (if that's what needs to be done.) The macro I made was --start it recording, choose a hotkey, select a row beneath where I wanted the first new rows to appear, select the row below that, go to "Insert" on the toolbar select row stop Macro recording. --no matter where I put the cursor, the news rows are added to the original place that I selected the rows to go. Bob |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro needed for inserting blank rows
You can use a procedure like the following. Uncomment the line of code you
want, depending on whether you want the inserted rows to be above or below the current active cell. Sub InsertTwoRows() '''''''''''''''''''''''''''''''' ' inserts rows ABOVE active cell '''''''''''''''''''''''''''''''' 'ActiveCell.Resize(2, 1).EntireRow.Insert '''''''''''''''''''''''''''''''' ' inserts rows BELOW active cell '''''''''''''''''''''''''''''''' 'ActiveCell(2, 1).Resize(2, 1).EntireRow.Insert End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "sunslight" wrote in message ... I need a macro to insert a set number of rows, scroll the mouse, hit the hotkey again and rows are inserted there. Specifically: I want to put the cursor on a row and have two new rows (blank) inserted beneath the row I have the mouse on. Just scroll the mouse to a row, click a hotkey, two new rows are inserted, scroll the mouse to a new location, hit the hotkey, two new rows inserted there--and so forth. I've tried; but my macro, every time I hit the hotkey, keeps adding row to the initial location. It is using absolute address instead of relative & I don't know how to get it to stop (if that's what needs to be done.) The macro I made was --start it recording, choose a hotkey, select a row beneath where I wanted the first new rows to appear, select the row below that, go to "Insert" on the toolbar select row stop Macro recording. --no matter where I put the cursor, the news rows are added to the original place that I selected the rows to go. Bob |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro needed for inserting blank rows
Is this better? (for few number of rows to insert)
For the first time select required row above which to insert a row, press Alt+I and R ( for inserting row) and then go to next required row and keep pressing F4 function key to repeat the last action (insert row, in this case) Regards Chip Pearson wrote: You can use a procedure like the following. Uncomment the line of code you want, depending on whether you want the inserted rows to be above or below the current active cell. Sub InsertTwoRows() '''''''''''''''''''''''''''''''' ' inserts rows ABOVE active cell '''''''''''''''''''''''''''''''' 'ActiveCell.Resize(2, 1).EntireRow.Insert '''''''''''''''''''''''''''''''' ' inserts rows BELOW active cell '''''''''''''''''''''''''''''''' 'ActiveCell(2, 1).Resize(2, 1).EntireRow.Insert End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "sunslight" wrote in message ... I need a macro to insert a set number of rows, scroll the mouse, hit the hotkey again and rows are inserted there. Specifically: I want to put the cursor on a row and have two new rows (blank) inserted beneath the row I have the mouse on. Just scroll the mouse to a row, click a hotkey, two new rows are inserted, scroll the mouse to a new location, hit the hotkey, two new rows inserted there--and so forth. I've tried; but my macro, every time I hit the hotkey, keeps adding row to the initial location. It is using absolute address instead of relative & I don't know how to get it to stop (if that's what needs to be done.) The macro I made was --start it recording, choose a hotkey, select a row beneath where I wanted the first new rows to appear, select the row below that, go to "Insert" on the toolbar select row stop Macro recording. --no matter where I put the cursor, the news rows are added to the original place that I selected the rows to go. Bob |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Code to Unhide Rows using Macro | Excel Worksheet Functions | |||
Step up blank rows | Excel Discussion (Misc queries) | |||
Macro Help Needed: Comparing cell values and deleting rows | Excel Discussion (Misc queries) | |||
Macro Help - Indefinite Rows | Excel Discussion (Misc queries) | |||
Macro Help In Excel | Excel Discussion (Misc queries) |