Thread: Changing Marco
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JBoyer JBoyer is offline
external usenet poster
 
Posts: 72
Default Changing Marco

I currently have two marcos that I would like to slightly change. They were
originally what I wanted, until I realized that by inserting and deleting
rows they were messing up other data on my sheet. Here are the two I have:

Sub InsertFiveRows()
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
v = Rows(LastRow - 1).Formula
Cells(LastRow - 1, "A").Resize(5, 1).EntireRow.Insert
Rows(LastRow - 1) = v
Rows(LastRow + 4).ClearContents
Range("AU2:BG6").Copy Cells(LastRow, "A")
End Sub

Sub DeleteFiveRows()
Dim lr As Long, x As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
x = lr - 5
ActiveSheet.Rows(x & ":" & lr -1).Delete
End Sub

Can you help me so that I can shift the cells up or down rather than
inserting and deleting cells.