For some reason my code is not working. I am getting "Error 91". I ran it fine with a "For each loop but this is not working for me.
It is telling me to debug at
strPrint = MsgBox(prompt:="Print " & shtCurrent & "?", Buttons:=vbYesNo + vbExclamation)
but I cannot find anything wrong with it.
Public Sub PrintWorksheets2()
'declare variables and assign address
Dim strPrint As String, intCount As Integer, wkbHours As Workbook, shtCurrent As Worksheet
Dim intSum As Integer, shtCount As Integer
Set wkbHours = Application.Workbooks("auco6215_HW10_Ex9.xlsm")
shtCount = wkbHours.Sheets.Count
intSum = 0
'ask user if he or she wants to print the worksheet
For intCount = 1 To shtCount
'shtCurrent = wkbHours
intSum = intSum + intCount
strPrint = MsgBox(prompt:="Print " & shtCurrent & "?", Buttons:=vbYesNo + vbExclamation)
If strPrint = vbYes Then 'if user wants to print
shtCurrent.PrintPreview
End If
Next intCount
End Sub
VbMsgBoxResult.