VBScript to Loop Through Records and Assign Cell Value - Bombing out?

Can another set of eyes take a lookat the following code and provide insight as to why its bombing out.  Basically it loops through the records found until end of file and I would like it to assign it to column A beginning at row 2 - whatever the number of records is found ... I know that because of this i have to add a counter (denoted by I) and therefore cannot write a static statement due to multiple records in the record set.  So I tried creating a string but the errror I'm getting is when I try executing the string (assuming its when I .value the thing) ... I think I'm missing a step here guys ... help?  It tells me Error Object Required: 'objWorksheet2.cells('
Code: 800A01A8
Yep totally missing a step ... ideas please?


objRecordset.Open "Select * FROM [Data$] Where LE<=#05/31/2008#", _
    objConnection, adOpenStatic, adLockOptimistic, adCmdText

dim i
dim cellvalueLE
dim cellvalueProj
dim cellvalueWarranty
dim exec
dim objWorksheet2

i=2
objExcel.Worksheets("PROJECTSAFTERQUERY").Activate
Set objWorksheet2 = objExcel.Sheets("PROJECTSAFTERQUERY")

Do Until objRecordset.EOF
 
'copy record to different spreadsheet

cellvalueLE = "objWorksheet2.cells(" & i & ",1)"

cellvalueLE.value = objRecordset.Fields.Item("LE")

i = i + 1
    objRecordset.MoveNext
Loop
justastefAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rory ArchibaldCommented:
If you only want the LE field, then try this:

objRecordset.Open "Select LE FROM [Data$] Where LE<=#05/31/2008#", _
    objConnection, adOpenStatic, adLockOptimistic, adCmdText

dim i
dim cellvalueLE
dim cellvalueProj
dim cellvalueWarranty
dim exec
dim objWorksheet2

objExcel.Worksheets("PROJECTSAFTERQUERY").cells(2,1).CopyFromRecordset objRecordset


Regards,
Rory
0
justastefAuthor Commented:
there are two other fields that I need (proj # and warranty) but I just wanted to start off with getting the LE to work ... thoughts?
0
Rory ArchibaldCommented:
Are you outputting the data as a table? If so, use the code above but change the SELECT statement to add the other two fields.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.