I know this has been asked many times on many different forums, which is where I got the code I'm using, but I just can't seem to get it to work correctly. My workbook has five worksheets, and my code is supposed to insert a blank row at the same spot on two of them, copying the formulae from the row above. However, all it ends up doing is inserting five blank rows with the formulae in the worksheet the user is viewing. Now, I did combine two codes from two different places, so I'm sure the problem is I didn't combine them properly (one for inserting the blank row, the other for doing it across multiple worksheets). The two worksheets I want this code to run on are labeled "Register" and "Budget". Here's my code:
Sub Insert_Rows()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Register" Or ws.Name <> "Budget" Then
If Selection.Rows.Count <> 1 Then Exit Sub
If Selection.Areas.Count <> 1 Then Exit Sub
With Selection.EntireRow
.Offset(-1).Copy
.Insert
On Error Resume Next
.Offset(-1).SpecialCells(xlCellTypeConstants, 23).ClearContents
On Error GoTo 0
End With
End If
Next ws
End Sub
Thanks for the help!
Bookmarks