![]() |
Display a Recordset in Excel
Hey everyone, I just found this board. I wrote some VBA
to query my SQL Server into a recordset, but I don't know how to display that recordset on my Excel spreadsheet. The recordset is full, so how do I put that into Excel? Here is the Last few lines of my code: 'Create Recordset rstIVSLH.CursorType = adOpenForwardOnly rstIVSLH.LockType = adLockReadOnly rstIVSLH.CursorLocation = adUseClient Set rstIVSLH = conSQLSERVERConnection.Execute(strSQL) 'ActiveSheet.Rows(3) = rstIVSLH.Fields ??????????????????? End Sub |
Display a Recordset in Excel
ActiveSheet.Range("A3").CopyFromRecordSet rstIVSLH
Regards, Tom Ogilvy "Alex A" wrote in message ... Hey everyone, I just found this board. I wrote some VBA to query my SQL Server into a recordset, but I don't know how to display that recordset on my Excel spreadsheet. The recordset is full, so how do I put that into Excel? Here is the Last few lines of my code: 'Create Recordset rstIVSLH.CursorType = adOpenForwardOnly rstIVSLH.LockType = adLockReadOnly rstIVSLH.CursorLocation = adUseClient Set rstIVSLH = conSQLSERVERConnection.Execute(strSQL) 'ActiveSheet.Rows(3) = rstIVSLH.Fields ??????????????????? End Sub |
Display a Recordset in Excel
Awesome! Thanks. You're Kung foo is the best.
Alex. |
Display the Header??
Tom, or anyone... Along with this solution is there a way to return the Header too, meaning the column names for the rows returned? |
Display the Header??
Dim TargetRange as Range
set Target.Range = ActiveSheet.Range("A3") For intColIndex = 0 To rs.Fields.Count - 1 ' the field names TargetRange.Offset(0, intColIndex). _ Value = rstIVSLH.Fields(intColIndex).Name Next TargetRange.Offset(1, 0).CopyFromRecordset _ rstIVSLH ' the recordset data -- Regards, Tom Ogilvy "Alex" wrote in message ... Tom, or anyone... Along with this solution is there a way to return the Header too, meaning the column names for the rows returned? |
Display the Header??
That's awesome man. Thanks again. You have showed me
the way to Yellow Belt in Kung VBA Foo. :} Take Care, Alex. |
All times are GMT +1. The time now is 03:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com