Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

method to fills cells on sheet without using recordset

vba excel 2010

dbconnectstring is from sql server.

What I'am doing:

Calling a sql server and putting data from that query in the sheet.

Currently using a recordset:


db.CursorLocation = adUseClient
   db.Open dbconnstring
   db.CommandTimeout = 6000
                With rs
                 .ActiveConnection = db
                 .Open sQuery
                End With
       cArrSql = rs.GetRows
        rs.MoveFirst
       
 Range("B6").Select

Do While rs.EOF = False
' ActiveCell.EntireRow.Insert ' insert a row to preserve original values
On Error Resume Next
 ActiveCell.Offset(0, 0).Value = rs.Fields(0)
    ActiveCell.Offset(0, 1).Value = rs.Fields(1)
     ActiveCell.Offset(0, 2).Value = rs.Fields(2)

etc.....

 rs.MoveNext
Loop


Is there  a faster way to present the data on the sheet?


thanks
fordraiders
ASKER CERTIFIED SOLUTION
Avatar of FamousMortimer
FamousMortimer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fordraiders

ASKER

Thanks. Worked great