Hello
I need to import a data table from SQL to Excel. I have the 2 queries in stored procedures (one that provides one part of the data table, and another provides the other half of the data in the table). What I want to do is for users to key in the start and end dates in Excel and the program should run itself and present the result data in Excel sheet. Is anything missing here?
Sub Outcome()
Dim avarParame As Variant
Dim avarValues As Variant
Dim avarResult As Variant
Dim avarResult2 As Variant
Dim wks As Worksheet
Dim strPath As String
Dim strFileName As String
'excel variables
Mnemonic = Range("strMnemonic")
datFrom = CDate(Range("DateFrom").Value)
datTo = CDate(Range("DateTo").Value)
ReDim avarParam(0 To 1)
ReDim avarValues(0 To 1)
avarParam(0) = "@datStart"
avarParam(1) = "@datCurrent"
avarValues(0) = datStart
avarValues(1) = datCurrent
'launch stored procedure1
avarResult = avarStoredProcedure("pTransaction1", avarParam, avarValues, "dbsMainBase")
Range(Range("Output"), Range("Output").Offset(UBound(avarResult, 1), UBound(avarResult, 2))) = avarResult
'launch stored procedure2
avarResult2 = avarStoredProcedure("pTransaction2", avarParam, avarValues, "dbsMainBase")
Range(Range("Output"), Range("Output").Offset(UBound(avarResult, 1), UBound(avarResult2, 2))) = avarResult2
End Sub
I need to import a data table from SQL to Excel. I have the 2 queries in stored procedures (one that provides one part of the data table, and another provides the other half of the data in the table). What I want to do is for users to key in the start and end dates in Excel and the program should run itself and present the result data in Excel sheet. Is anything missing here?
Sub Outcome()
Dim avarParame As Variant
Dim avarValues As Variant
Dim avarResult As Variant
Dim avarResult2 As Variant
Dim wks As Worksheet
Dim strPath As String
Dim strFileName As String
'excel variables
Mnemonic = Range("strMnemonic")
datFrom = CDate(Range("DateFrom").Value)
datTo = CDate(Range("DateTo").Value)
ReDim avarParam(0 To 1)
ReDim avarValues(0 To 1)
avarParam(0) = "@datStart"
avarParam(1) = "@datCurrent"
avarValues(0) = datStart
avarValues(1) = datCurrent
'launch stored procedure1
avarResult = avarStoredProcedure("pTransaction1", avarParam, avarValues, "dbsMainBase")
Range(Range("Output"), Range("Output").Offset(UBound(avarResult, 1), UBound(avarResult, 2))) = avarResult
'launch stored procedure2
avarResult2 = avarStoredProcedure("pTransaction2", avarParam, avarValues, "dbsMainBase")
Range(Range("Output"), Range("Output").Offset(UBound(avarResult, 1), UBound(avarResult2, 2))) = avarResult2
End Sub