Use the VBA Find method, like this:
Sub Find_Print_Area()
Dim EDcell As Range
Dim printCells As Range
Set EDcell = Range("ED15:ED515").Find(What:="1", After:=Range("ED515"), LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False, SearchFormat:=False)
If Not EDcell Is Nothing Then
Set printCells = Range("A1", EDcell)
MsgBox "Last 1 in column ED: " & EDcell.Address & vbCrLf & "Print area range: " & printCells.Address
Else
MsgBox "1 not found in column ED"
End If
End Sub
I used the Macro Recorder to generate the Find call and edited the code. The printCells range gives you the print area range, which you could use as an argument to macro recorder-generated code whilst setting the print area.
Bookmarks