Red over White
Board Regular
- Joined
- Jul 16, 2011
- Messages
- 132
- Office Version
- 365
- Platform
- MacOS
I have been using the Call function without too many problems, but am now getting an error message - Compile error: Expected Sub, Function or Property
The VBA code is
The macro 'OpenTax' comes straight after 'PrintRun' in the same Module, and works as intended. I suspect the problem is around the If statements, or possibly the fact I have two "If Ans = vbYes Then" statements without a "vbNo" statement in between.
Any suggestions?
The VBA code is
Rich (BB code):
Sub PrintRun()
Call Graph ' this one doesn't generate the error
Dim Config As Integer
Dim Ans As Integer
Config = vbYesNo + vbQuestion + vbDefaultButton1
Ans = MsgBox("If a QE answer Yes.", Config)
If Ans = vbYes Then
' Lines of code printing off various sheets, the code carrying on with
Application.DisplayAlerts = False
Dim Config1 As Integer
Dim Ans1 As Integer
Dim OpenTax as Boolean
Dim Tax as Workbook
Config1 = vbYesNo + vbQuestion + vbDefaultButton1
Ans1 = MsgBox("Tax calculation to print?", Config)
If Ans1 = vbYes Then
Call OpenTax ' this is where I get the error message
Sheets("Tax calculation").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1 ' Sheet 4
Workbooks.Close FileName:= _
"/Users...2011.xlsm"
Application.DisplayAlerts = True
End If
If Ans = vbNo Then
' The code then carries on
The macro 'OpenTax' comes straight after 'PrintRun' in the same Module, and works as intended. I suspect the problem is around the If statements, or possibly the fact I have two "If Ans = vbYes Then" statements without a "vbNo" statement in between.
Any suggestions?
Last edited by a moderator: