LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Insert Multiple Rows - variable

Sub tst()
x = InputBox("How many rows ")
ActiveCell.Resize(x, 1).EntireRow.Insert
End Sub


"Steve" skrev:

Hello. Below is my code that inserts a row in multiple sheets based
on where the active cell is. This inserts one row at a time. The
users often need to insert many rows. How can I prompt the user to
ask how many rows they would like to insert, and then have vba use
that input and insert that many rows? Thanks!!


Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", )).Select
Sheets("Sheet1").Activate

ActiveCell.Offset(1, 0).EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(-2, 0).Select
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1, 0).EntireRow.Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.End(xlToLeft).Select


 
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
how do insert multiple rows in between multiple lines Ernie Excel Discussion (Misc queries) 1 January 15th 07 10:55 PM
Insert Variable Number of Rows; With Loop ryguy7272 Excel Worksheet Functions 2 December 27th 06 08:25 PM
Need to insert formula to a variable number of rows edoc abv Excel Programming 1 September 26th 05 04:12 AM
insert variable number of rows tina Excel Programming 1 February 9th 05 01:18 PM
Insert rows in depending on criteria in variable columns jeffbert Excel Programming 2 October 4th 04 06:53 PM


All times are GMT +1. The time now is 02:28 PM.

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

About Us

"It's about Microsoft Excel"