How can I limit Excel worksheet to 12 pages?

  • Thread starter Thread starter Fredfixit
  • Start date Start date
F

Fredfixit

I am new at using Excel and I want to limit the amount of pages on a
worksheet from 1 to 12 pages. How do I end it so I don't have hundreds of
pages in my file?
 
Getting the page count for a sheet in Excel is sometimes a bit iffy, but you
can get a good approximation. Rather than going through a lot of code to
actually lock up a sheet at some point that might or might not be when you
want to, you can alert yourself when you select a sheet and then make the
decision to continue using it or not.

Put the following code into the worksheet event for each worksheet you want
to keep an eye on. To put the code into the worksheet's event handling area,
choose the sheet, right-click on the worksheet's tab and choose [View Code]
from the list, then copy the code below and paste it into the module
presented to you.

Private YouHaveBeenWarned As Boolean

Private Sub Worksheet_Activate()
If Not YouHaveBeenWarned Then
MsgBox "This sheet is now approximately " & _
ActiveSheet.HPageBreaks.Count * ActiveSheet.VPageBreaks.Count + 1 & _
" printout pages in size."
YouHaveBeenWarned = True
End If
End Sub

Private Sub Worksheet_Deactivate()
YouHaveBeenWarned = False
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not YouHaveBeenWarned Then
MsgBox "This sheet is now approximately " & _
ActiveSheet.HPageBreaks.Count * ActiveSheet.VPageBreaks.Count + 1 & _
" printout pages in size."
YouHaveBeenWarned = True
End If
End Sub
 
Back
Top