I want to call sub with multiple argument but I got an error Syntax error
I tried it on Ms Excel 2013
Sub Withdrawal(Query As String, Savelocation As String)
'Query Data
Dim ReturnArray
Dim Conn As New ADODB.Connection
Dim mrs As New ADODB.Recordset
Dim DBPath As String, sconnect As String
DBPath = Application.ActiveWorkbook.Path + "\Data.xlsx"
sconnect = "Provider=MSDASQL.1;DSN=Excel Files;DBQ=" & DBPath & ";HDR=Yes';"
Conn.Open sconnect
mrs.Open Query, Conn
ThisWorkbook.Worksheets(Savelocation).Range("A3").CopyFromRecordset mrs
mrs.Close
Conn.Close
End Sub
Sub CashWithdrawal()
Dim CashWFYC As String
Dim Location As String
Location = "CashWithdrawal"
CashWFYC = "SELECT TOP 10 * FROM [TT$]"
sSQLSting = CashWFYC
Withdrawal(sSQLSting, Location)
End Sub
I expect the output that got from that sSQLSting query should be save in Location
Withdrawal sSQLSting, Location(FYI, this has come up many, many times before)Withdrawal (sSQLSting, Location), notWithdrawal(sSQLSting, Location). That space is the VBE telling you "this isn't an argument list, it's an expression I'm going to try to evaluate and passByValas the first argument to theWithdrawalprocedure".