View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Print only if Cell is non-blank

subscript out of range for the following code would be an indication the
sheet is not named exactly "Sheet1". There may be a space somewhere in the
name as an example.

--
Regards,
Tom Ogilvy


"Eric" wrote:

I am getting an "out-of-range" error on this code:

Private Sub PrintButton1_Click()

If IsEmpty(Worksheets("Sheet1").Range("A8").Value) Then
Worksheets("Sheet1").PrintOut Copies:=1
End If

End Sub

I have a command button set up such that when clicked, the code should check
a certain cell on each sheet of a workbook and print the sheets that have
some value in that cell. Any ideas??