![]() |
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 |
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 |
How to get in a vbs script the sum of values of a Excel cells in a
This looks like VBA.
Doesn't OP want vbscript? Gord Dibben MS Excel MVP On Thu, 26 Jun 2008 10:58:00 -0700, RyanH wrote: 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! |
All times are GMT +1. The time now is 01:33 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com