Issue with passing values

  • Thread starter Thread starter associates
  • Start date Start date
A

associates

Hi,

I was wondering if anyone might be able to help me.

I was trying to create a function that takes 2 arguments and i go
compiler error messages saying i need '=' expected.

Here is my code

filein = Application.GetOpenFilename()
ImportCSV (mysheet, filein)

in the function of ImportCV, i have
Function ImportCSV(sheet As String, inputfile As String)

...

end function

Any ideas?

Thank you in advanc
 
Sub ImportCSV(sheet As String, inputfile As String)

Since ImportCSV does not return a value, it is a Sub, not a Function

HTH
 
Try removing the ()'s and make sure you pass the correct type of parms to the
function:

Option Explicit
Sub testme()
Dim mySheet As String
Dim inputfile As String
inputfile = Application.GetOpenFilename()
ImportCSV mySheet, inputfile
End Sub
Function ImportCSV(sheet As String, inputfile As String)
'do the work
MsgBox "hi"
End Function
 
Ps. You can keep the ()'s if you use Call:

Option Explicit
Sub testme()
Dim mySheet As String
Dim inputfile As String
inputfile = Application.GetOpenFilename()
Call ImportCSV(mySheet, inputfile)
End Sub
Function ImportCSV(sheet As String, inputfile As String)
'do the work
MsgBox "hi"
End Function
 

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