Andrew Perry
Andrew Perry

Reputation: 765

Calling a VBA sub with arguments gives a syntax error

I have the following variables in use in a set of subs:

Public WeightCap As Double  ' Weight capacity
Public HeightCap As Double  ' Height capacity
Public WeightRunning As Double  ' Weight running total
Public HeightRunning As Double  ' Height running total
Public WeightRunningCheck As Double  ' Weight running total for check
Public HeightRunningCheck As Double  ' Height running total for check

With these, I'm trying to call the RTFiller sub as follows:

HeightRunningCheck = HeightRunning + wsStacker.Cells(iSrcCountLine + 1, 12).Value
WeightRunningCheck = WeightRunning + wsStacker.Cells(iSrcCountLine + 1, 13).Value
RTFiller(HeightRunningCheck, WeightRunningCheck)

The RTFiller sub is defined thus:

Private Sub RTFiller(HeightTot As Double, WeightTot As Double)

However, trying to run it prompts a syntax error on the RTFiller(HeightRunningCheck, WeightRunningCheck)line, and when I try to debug it I get "Compile error: Expected: ="

I must have forgotten something obvious and vital, but I can't for the life of me figure out what. Any help?

Upvotes: 0

Views: 1402

Answers (1)

Rory
Rory

Reputation: 34045

You either use:

Call RTFiller(HeightRunningCheck, WeightRunningCheck)

or:

RTFiller HeightRunningCheck, WeightRunningCheck

Unless you use Call, or are returning a value from a function (or are specifically trying to dereference/evaluate one of the parameters) you don't use parentheses.

Upvotes: 2

Related Questions