How do you insert a row into all worksheets?

lbass

Board Regular
Joined
Aug 15, 2002
Messages
104
I found you can group all the sheets using
sheets.select
But even with all the sheets grouped
inserting a row happens only with the last active sheet.

How can I insert a row in all the worksheets?

Thanks

Yes I tried searching - guess I just didn't know what to search for.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
untested --

sheets.select
rows("1:1").select
with selection
.insert shift:=xldown
end with
 
Upvote 0
How about something like this:
Code:
Sub InsertRows()
    Dim ws As Worksheet
        For Each ws In ActiveWorkbook.Worksheets
            ws.Activate
            Range("A1").EntireRow.Insert
        Next ws
End Sub
Hope that helps,

Smitty
 
Upvote 0
select all the sheet tabs for those you want to insert into,
select the row number you are inserting,

right click, insert.

Digglez
 
Upvote 0
Hi:

The procedure the OP works on my 2002 version....what version are you using?

plettieri
 
Upvote 0
Thanks - I haven't checked Smitty's yet - all the rest work.

How do I get it to do it just above the cursor, where ever it may be?
 
Upvote 0
How do I get it to do it just above the cursor, where ever it may be?
How's this:
Code:
Sub InsertRows()
    Dim ws As Worksheet
        For Each ws In ActiveWorkbook.Worksheets
            ws.Activate
            If ActiveCell.Row <> 1 Then
                ActiveCell.Offset(-1, 0).EntireRow.Insert
                Else: ActiveCell.EntireRow.Insert
            End If
        Next ws
End Sub
Hope that helps,

Smitty
 
Upvote 0
Supper!!!!

When I checked out your first reply it worked fine just inserted above A1.

Thanks
 
Upvote 0
Need just a little more help.
say there are 10 sheets A1:a44 have 1-44 in them
first sheet active cell is A1 = 1
Second sheet is A2 = 2
and so on
in sheet 10 (active sheet) active cell is a10 = 10 and want to insert row so that A10 is blank and A11 = 10
And want this to happen in all the sheets

I can get it to happen to only sheet 10 or I can get
A1 blank and A2 = 1 in all the sheets

I can not figure how to lock sheet 10 A10 as the active cell and
have A10 become the active cell in all the sheets.

Thanks for your help
 
Upvote 0
the below doesn't work?
Sub foo()
Sheets.Select
Rows("10:10").Select
With Selection
.Insert shift:=xlDown
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,027
Messages
6,128,381
Members
449,445
Latest member
JJFabEngineering

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top