View Single Post
  #2   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.excel.misc,microsoft.public.excel.programming
RyanH RyanH is offline
external usenet poster
 
Posts: 586
Default How to get in a vbs script the sum of values of a Excel cells in a

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