I am trying to create a macro that will print a sheet based on a named cell in the sheet's contents. I have this:
Sub PrintSheets()
Dim Sh As Worksheet
Dim Printed
For Each Sh In ThisWorkbook.Worksheets
If Sh.CodeName <> "Sample" Then
If Sh.Range("Name") <> "" Then
Sh.PrintOut copies:=1
End If
End If
Next Sh
End Sub
Name is the named cell on each sheet.
But it returns this error:
method range of object _worksheet failed
I am a complete newbie to macro's, TIA!
Sub PrintSheets()
Dim Sh As Worksheet
Dim Printed
For Each Sh In ThisWorkbook.Worksheets
If Sh.CodeName <> "Sample" Then
If Sh.Range("Name") <> "" Then
Sh.PrintOut copies:=1
End If
End If
Next Sh
End Sub
Name is the named cell on each sheet.
But it returns this error:
method range of object _worksheet failed
I am a complete newbie to macro's, TIA!