Insert Row without Selecting

D

David Jenkins

I'd like to be able to insert a new row without having to
select a row first. This is the syntax I'm using (from a
recorded macro):

TargCell.EntireRow.Select
Selection.Insert Shift:=xlDown

I don't want to have to do a select because the sheet I'm
manipulating is (windows(sheetname).visible = false), and
currently I have to "unhide" it in order to insert the
row, or I get an error trying to do the select when it's
hidden.

Any help would be appreciated.

David Jenkins
 
J

Jake Marx

Hi David,

David said:
I'd like to be able to insert a new row without having to
select a row first. This is the syntax I'm using (from a
recorded macro):

TargCell.EntireRow.Select
Selection.Insert Shift:=xlDown

I don't want to have to do a select because the sheet I'm
manipulating is (windows(sheetname).visible = false), and
currently I have to "unhide" it in order to insert the
row, or I get an error trying to do the select when it's
hidden.

TargCell.EntireRow.Insert Shift:=xlDown

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
D

David Jenkins

Beautiful! Thanks, Jake!

-----Original Message-----
Hi David,

David said:
I'd like to be able to insert a new row without having to
select a row first. This is the syntax I'm using (from a
recorded macro):

TargCell.EntireRow.Select
Selection.Insert Shift:=xlDown

I don't want to have to do a select because the sheet I'm
manipulating is (windows(sheetname).visible = false), and
currently I have to "unhide" it in order to insert the
row, or I get an error trying to do the select when it's
hidden.

TargCell.EntireRow.Insert Shift:=xlDown

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
.
 
M

mangesh_yadav

Worksheets(SheetName).Rows("10:10").EntireRow.Insert

if you try to select a hidden sheet you get an error. so do not use
select. use the insert directly. The above line inserts row 10

- Manges
 
Top