Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to Unhide Rows using Macro Rajat Excel Worksheet Functions 7 January 14th 10 06:56 PM
Step up blank rows Jenny B. Excel Discussion (Misc queries) 3 December 16th 06 05:35 AM
Macro Help Needed: Comparing cell values and deleting rows [email protected] Excel Discussion (Misc queries) 1 September 19th 06 02:39 AM
Macro Help - Indefinite Rows piano.lisa Excel Discussion (Misc queries) 3 August 16th 06 05:47 PM
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM


All times are GMT +1. The time now is 12:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"