On every other page of my workbook I have data in cells A4:O459 and I would like to extend the last 8 rows with their formulas and cut/paste all rows excluding the top 8 over all the rows. The result being that I have 8 fresh rows at the bottom and the oldest 8 at the top are gone.
On every other page I have data in cells B3:I59 and I would like to do the same thing but only create/get rid of 1 row.
The following code seems to be cutting and pasting A4:O459 on every page, despite the Case statement. I end up with an error saying that it can't paste into an area smaller than the selection. Why is this happening?
On every other page I have data in cells B3:I59 and I would like to do the same thing but only create/get rid of 1 row.
The following code seems to be cutting and pasting A4:O459 on every page, despite the Case statement. I end up with an error saying that it can't paste into an area smaller than the selection. Why is this happening?
Code:
Sub getNewRows()
Dim ws As Worksheet
For Each ws In Worksheets
Select Case ws.Name
Case "sheet1", "sheet3"
Range("A4:O459").Select 'select current data
Selection.AutoFill Destination:=Range("A4:O467"), Type:=xlFillSeries 'extend 8 lines
Range("A12:O467").Select 'grab all except top 8
Selection.Cut
Range("A4").Select 'paste where original were
ws.Paste
Case "sheet2", "sheet4"
Range("B3:I59").Select 'select current data
Selection.AutoFill Destination:=Range("B3:I60"), Type:=xlFillSeries 'extend 1 line
Range("B3:I60").Select
Range("B4:I60").Select 'grab all except top 1
Selection.Cut
Range("B3").Select 'paste where original were
ws.Paste
End Select
Next ws
End Sub
Last edited by a moderator: