By using vba.booksticle.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

948 Steps to 6 Figures by Learning Excel-VBA and Other Skills



Step 480 - LoadSQLtoSheet


Sub LoadSQLToSheet(sSQL As String)
'Load results to active cell

'CreateSheet sTicker
Dim rs As ADODB.Recordset
Dim i As Long




Set rs = GetRecordset(sSQL)

For i = 0 To rs.Fields.Count - 1
    ActiveCell = rs(i).Name
    If rs(i).Type = adDBTimeStamp Then
        Columns(i + 1).NumberFormat = "mm/dd/yy"
    End If
    
    Right1
Next

Down1
Cells(AR, 1).Select


Do While Not rs.EOF
    For i = 0 To rs.Fields.Count - 1
        ActiveCell = rs(i)
        Right1
    Next

    Down1
    Cells(AR, 1).Select


    rs.MoveNext
    DoEvents
    
Loop







End Sub

   Table of Contents | Send us your feedback | © 2025 All Rights Reserved | Edit