Sub with two parameters

eoinymc

Board Regular
Joined
Jan 29, 2009
Messages
203
Hello there,

So, I have a main sub where most of my code is called split data:

Code:
Sub SplitData()
'Code code code code code code
FRD = 1
BTop = 1
FRS = 8
FRO = 11
FRL = 20

LoopSum(FRD, BTop)
LoopSum(FRS, FRD)
LoopSun(FRO, FRS)
'....etc...


End Sub

So, I have LoopSum defined as this:

Code:
Sub LoopSum(LS As String, Tp As String)
 
    Dim Links As Worksheet
    Set Links = Sheets("Links")
 
    Links.Cells(LS, 6) = "=SUM(F" & Tp & ":F" & LS - 1 & ")"
    Links.Range(Cells(LS + 1, 6), Cells(LS + 1, 16)).ClearContents
   
End Sub

However, I'm getting the following error

Compile Error: Expected: =

Has anyone got any idea why this is?

Has it something got to do with the way that I am calling the two parameters in LoopSum or should I have the Sub named Private Sub or Public Sub or something like that?

Also, please don't tell me how to do it a different way. This is a snapshot of the code in both SplitData and LoopSum. :):):)

Thanks,

E
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try removing the parentheses (and for clarity add Call):

Call LoopSum FRD, BTop

They are only required when you are assigning the result of a function to a variable.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top