Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How to get in a vbs script the sum of values of a Excel cells in a certain range?

Reply
 
Old 06-26-2008   #1 (permalink)
Claudia d'Amato


 
 

How to get in a vbs script the sum of values of a Excel cells in a certain range?

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


My System SpecsSystem Spec
Old 06-26-2008   #2 (permalink)
RyanH


 
 

RE: 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:
Quote:

> 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
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Coloring the cells and text in Excel 7 Microsoft Office
a little problem with .Range(.Cells(2,1),.Cells(2,49)). VB Script
Excel / .Net: Extract a given Range into Picture or X(HT)ML? .NET General
How to delete the content of Excel cells from VBS script? VB Script
Can't create uint32 values outside int32 range? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46