Assume I want to get the sum of values of all cells from the range "H6:H18" from an Excel Worksheet.

How can I do this within vbs script?

Claudia

RE: How to get in a vbs script the sum of values of a Excel cells in a by RyanH

RyanH
Thu Jun 26 12:58:00 CDT 2008

This will definitely work for you.

Sub SumRange()

Dim myRange As Range
Dim cell As Range
Dim rngtotal As Double

Set myRange = Sheets("Sheet1").Range("H6:H18")

For Each cell In myRange
rngtotal = rngtotal + cell
Next cell

MsgBox "The Sum of Range(''H6:H18'') = " & rngtotal

End Sub

Hope it helps!
--
Cheers,
Ryan


"Claudia d'Amato" wrote:

> Assume I want to get the sum of values of all cells from the range "H6:H18" from an Excel Worksheet.
>
> How can I do this within vbs script?
>
> Claudia
>
>