View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_4_] Dick Kusleika[_4_] is offline
external usenet poster
 
Posts: 595
Default 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