# need to know how to sum numbers in column G of excel spreadsheet in VBsedit. visual basic

i have an external excel spreadsheet version 2003, column A contains about 5 rows of numeric values.  i need to create a SUM function in vbsedit that totals these rows from column A in excel and passes it as a variable within my vbsedit script.  i need step-by-step as  I can't find sum function within vbsedit program at all.

my range is Range("A2:A100") and I need to create a vbsedit script and then pass the total into the following function where r is going to be this total from coulmn A.

line="SCH" & sep & r & sep & "EA***169*20(ddate)"
LVL 1
###### 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.

Commented:
One option:

Dim i As Integer
Dim r As Integer
For i = 2 To 100
r += objSheet.Range("A" & i).Value
Next
0
Author Commented:
thank you very much for respoding but it did not work....errored out w/ "end of statement expected"..please help

Dim i As Integer
Dim r As Integer
For i = 2 To 100
r += objSheet.Range("G" & i).Value
Next

biaST = "ST*846*0001~BIA*00*SI" & sep & Vendor & sep & "20(ddate)"
item = "LIN**VP*(Column2)*DP*N~QTY*33*(Column7)*EA"
line="SCH" & sep & r & sep & "EA***169*20(ddate)"
0
Author Commented:
can anyone help?
0
Author Commented:
wow, I cannotbelieve noone had responded, i've asked one question in several months and can't even get help.
0
Billing EngineerCommented:
the "r += xx" syntax won't work indeed...
you need the plain "r = r + xxx" ...

``````Dim i As Integer
Dim r As Integer
For i = 2 To 100
r = r + objSheet.Range("A" & i).Value
Next
``````
0
Billing EngineerCommented:
you might instead also use the worksheetfunction stuff:
``````Dim r as integer
r = Application.WorksheetFunction.Sum(objSheet.Range("A1:A200¿))
``````
0

Experts Exchange Solution brought to you by

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

###### 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
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.