ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro adding line (https://www.excelbanter.com/excel-programming/385685-macro-adding-line.html)

rick_mc

Macro adding line
 
I need to create a macro that runs a SQL query and assigns the output to the
next row in the report. The report is additive, new data is always added to
the next available row. How do you assign the SQL output to the next row?

Dick Kusleika[_4_]

Macro adding line
 
On Tue, 20 Mar 2007 07:52:05 -0700, rick_mc
wrote:

I need to create a macro that runs a SQL query and assigns the output to the
next row in the report. The report is additive, new data is always added to
the next available row. How do you assign the SQL output to the next row?


Something like this:

Dim rng As Range
Dim rs As ADODB.Recordset

Set rng = Sheet1.Cells(Sheet1.Rows.Count, 1).End(xlUp).Offset(1, 0)
'Get recordset here

rng.CopyFromRecordset rs
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com


All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com