Debug problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

The code below will not compile. It say 'Expected Sub, Function or Property' I can't see the problem?

Thanks in advance,
James

Option Explicit


Sub OptionsPrintPack()

Dim PrintOrder As Integer

Dim PrintTitle(11)
PrintTitle(1) = "Ethnic Profile by Gender"
PrintTitle(2) = "Ethnic Profile by Gender by Site"
PrintTitle(3) = "Ethnic Profile by Gender by Role"
PrintTitle(4) = "Years fo Service"
PrintTitle(5) = "Years of Service by Site"
PrintTitle(6) = "Average Age by Site, By Gender, by Age"
PrintTitle(7) = "Average Age Profile by Site"
PrintTitle(8) = "Total Salary By Site"
PrintTitle(9) = "Average Salary by Site and Gender"
PrintTitle(10) = "Average Managers Salary by Site and Gender"
PrintTitle(11) = "Basic Salary shown in a Range"

Dim PrintMacro(11)
PrintMacro(1) = "CreateEthnicProfileByGender"
PrintMacro(2) = "CreateEthnicProfileByGenderBySite"
PrintMacro(3) = "CreateEthnicProfileByGenderByRole"
PrintMacro(4) = "CreateYearsOfServiceProfile"
PrintMacro(5) = "CreateServiceProfileBySite"
PrintMacro(6) = "CreateAvAgeBySiteByGenderbyAge"
PrintMacro(7) = "CreateAgeProfileBySite"
PrintMacro(8) = "CreateTotalBasicSalaryBySite"
PrintMacro(9) = "CreateAverageBasicSalaryBySiteAndGender"
PrintMacro(10) = "CreateMgtBasicSalaryBySiteByGender"
PrintMacro(11) = "CreateBasicSalaryByRange"


For PrintOrder = 1 To 11

Sheets("PivotChart").Select

Call PrintMacro(PrintOrder)


Next PrintOrder


' Application.Dialogs(xlDialogPrint).Show ' choose printer

End Sub
 
You have defined PrintMacro as an array, then try to call it as if it were a
sub. You need to use the name of an actual sub in your call statement.

--
Regards,
Tom Ogilvy

James L said:
Hello,

The code below will not compile. It say 'Expected Sub, Function or
Property' I can't see the problem?
 
Hi
Call expects a sub or function name and not an array with function/sub
names

--
Regards
Frank Kabel
Frankfurt, Germany

James L said:
Hello,

The code below will not compile. It say 'Expected Sub, Function or
Property' I can't see the problem?
 
Hi James,

There seems to be some confusion here. The error is on the line

Call PrintMacro(PrintOrder)

and there is no sub called PrintMacro. You do have an array caled
PrintMacro, which holds 11 stringd, presumably what you are trying to
process. You probably have another sub called something else, let's call
ChartSetup now, and the sub call should be something like

Call ChartSetup(PrintMacro(PrintOrder))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

James L said:
Hello,

The code below will not compile. It say 'Expected Sub, Function or
Property' I can't see the problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top