Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Multiple Rows in Excel using VBA 1

Status
Not open for further replies.

arbeeone

Technical User
Jul 17, 2005
11
AU
Hi,
I want to insert multiple rows into a worksheet using VBA.
I can insert a single row using:
Rows(r).Insert - where r is the row number
But, Rows(r:r1).Insert (where r1 is the last row number) doesn't work. I've tried using the Cells method for the Range but this also gives me problems. I can use a loop to insert single lines from 'r' to 'r1', but I suspect a single command would be more efficient (and neater!).

Any help would be greatly appreciated!

rsb
 
I've tried this, but the problem is that the macro recorder gives specific row numbers (e.g. Rows("10:11") ) but I want to have them as variable names. I've tried Rows("r:r1") and Rows(r:r1) but neither seem to work.
rsb
 
well use a bit of logic then

rows(StartRow & ":" & EndRow).delete

Alternatively

Range("A1:A10").entirerow.delete would work

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
Thanks Geoff,
I'd tried 2 or 3 different combinations of concatenation but not that one!
rsb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top