Created
August 7, 2023 14:26
-
-
Save stevesohcot/4937c90667c0db9e5741725a6bbfdd50 to your computer and use it in GitHub Desktop.
Excel VBA call function for Stored Procedure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub getDataFromRecordset() | |
Dim sheet As String | |
sheet = "Data" | |
Worksheets(sheet).Select | |
Range("A1").Select | |
Set rPrint = Worksheets(sheet).Range("A2") | |
Dim rst As New ADODB.Recordset | |
Set rst = getInfoFromStoredProcedure() | |
If Not rst.EOF Then | |
rPrint.CopyFromRecordset rst | |
End If | |
rst.Close | |
' Cells.Select | |
' Selection.ColumnWidth = 50.86 | |
' Cells.EntireColumn.AutoFit | |
' Cells.EntireRow.AutoFit | |
Range("A1").Select | |
MsgBox " Report downloaded" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment