Syntax Error on Function pass?

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
Why am I getting a syntax error? Calling from a userform button. Thanks

Code:
Private Sub CommandButton1_Click()
Dim modname As String
Dim twb As String
strfiletoopen = Application.GetOpenFilename _
(Title:="Please choose a file to open", _
FileFilter:="Excel Files *.xls* (*.xls*),")
'CopyModule(strFiletoopen, "Module1", ThisWorkbook)
modname = "test1"
twb = "test2"
[COLOR=#ff0000]testit (strfiletoopen,modname,twb)[/COLOR]
End Sub
Code:
Function testit(sourcewb As String, modname As String, targetwb As String)
MsgBox sourcewb & "--" & modname & "--" & targetwb
End Function
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Remove the brackets or use Call.
Code:
Private Sub CommandButton1_Click()
Dim modname As String
Dim twb As String
Dim strfiletoopen As String

    strfiletoopen = Application.GetOpenFilename _
                    (Title:="Please choose a file to open", _
                     FileFilter:="Excel Files *.xls* (*.xls*),")
    'CopyModule(strFiletoopen, "Module1", ThisWorkbook)
    modname = "test1"
    twb = "test2"
    testit strfiletoopen, modname, twb
End Sub
 
Upvote 0
Remove the brackets or use Call.
Code:
Private Sub CommandButton1_Click()
Dim modname As String
Dim twb As String
Dim strfiletoopen As String

    strfiletoopen = Application.GetOpenFilename _
                    (Title:="Please choose a file to open", _
                     FileFilter:="Excel Files *.xls* (*.xls*),")
    'CopyModule(strFiletoopen, "Module1", ThisWorkbook)
    modname = "test1"
    twb = "test2"
    testit strfiletoopen, modname, twb
End Sub

duh, perfect -- thanks!
 
Upvote 0

Forum statistics

Threads
1,215,215
Messages
6,123,668
Members
449,114
Latest member
aides

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