Avatar of Fordraiders
Fordraiders
Flag 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
Microsoft Excel

Avatar of undefined
Last Comment
Fordraiders

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
FamousMortimer

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Fordraiders

ASKER
Thanks. Worked great
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck