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

expertatexcel.com

 


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