# 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?

x
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
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)"
Author Commented:
can anyone help?
Author Commented:
wow, I cannotbelieve noone had responded, i've asked one question in several months and can't even get help.
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
``````
Billing EngineerCommented:
you might instead also use the worksheetfunction stuff:
``````Dim r as integer
r = Application.WorksheetFunction.Sum(objSheet.Range("A1:A200¿))
``````

Experts Exchange Solution brought to you by