We help IT Professionals succeed at work.
Get Started

method to fills cells on sheet without using recordset

Fordraiders asked
Last Modified: 2014-05-02
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

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)



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

Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE