cgeorge4
Board Regular
- Joined
- Jul 24, 2011
- Messages
- 91
Excel 2007 and 2010
Windows 7
This should be easy for me but it's not working.
1) I have a workbook with a Master tab named "pivot sequence".
2) The other sheets in this same workbook have different names - and their header titles are all on row 1.
I need to insert 5 blank rows above the header row on each sheet (except the "pivot sequence" sheet).
Essentially moving the range of data down 5 rows.
I recorded inserting 3 rows above the range of data on one sheet, then made changes so it would loop thru the other sheets.
My code below inserts 14 rows for some reason, and only on the sheet selected.
I would need this code to work on all sheets - no matter what sheet happens to be selected at the time.
I can't see where my error is. Any help would be appreciated.
Thank you in advance,
Juicy
Windows 7
This should be easy for me but it's not working.
1) I have a workbook with a Master tab named "pivot sequence".
2) The other sheets in this same workbook have different names - and their header titles are all on row 1.
I need to insert 5 blank rows above the header row on each sheet (except the "pivot sequence" sheet).
Essentially moving the range of data down 5 rows.
I recorded inserting 3 rows above the range of data on one sheet, then made changes so it would loop thru the other sheets.
My code below inserts 14 rows for some reason, and only on the sheet selected.
I would need this code to work on all sheets - no matter what sheet happens to be selected at the time.
I can't see where my error is. Any help would be appreciated.
Code:
Sub Insert5_Rows_Loop()
Dim wks As Worksheet
For Each wks In Worksheets
If LCase(wks.Name) <> "pivot sequence" Then
Rows("1:1").Select
Range("A1").Activate
Selection.Insert Shift:=xlDown
End If
Next wks
End Sub
Thank you in advance,
Juicy