The problem is that if this macro is run more than once it creates a second OLEObect on top of the first. If it could start at the first hidden row that would probably solve the problem. Alternately, if it could be made to check for the presence of an OLEobject and only insert the new one if there isn't already one there, that would definately work. thanks in advance for any advice!
Code:
Sub sheetSetup()
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim rng As Range
Dim StartingRow As Long
StartingRow = 43
k = 0
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
nFirstRow = r.Row
For n = nFirstRow To nLastRow
If Cells(n, "A").EntireRow.Hidden Then
Else
k = k + 1
End If
If k = 44 Then
k = 1
Cells(n + 30, "B").Select
Set rng = Cells(n + 30, "B")
ActiveSheet.OLEObjects.Add(ClassType:="Word.DocumentMacroEnabled.12", Link _
:=False, DisplayAsIcon:=False, Width:=540).Select
With Selection
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Fill.Visible = msoFalse
.ShapeRange.Line.Visible = msoFalse
.Top = rng.Top
.Left = rng.Left
.Height = 180
End With
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(n, "A")
End If
Next
Selection.Delete
Range("F19").Select
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub