Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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

  #2   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.excel.misc,microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete the content of Excel cells from VBS script? Claudia d'Amato Excel Discussion (Misc queries) 2 June 21st 08 12:55 PM
If certain cells not blank, and cells in range are, set values to ktoth04 Excel Discussion (Misc queries) 0 February 21st 08 09:01 PM
Count values in a range of cells Loralei Excel Worksheet Functions 3 November 13th 07 11:13 PM
Find a range of values in a range of cells Jack Taylor Excel Worksheet Functions 20 November 25th 06 01:26 PM
How do I sum the absolute values of a range of cells? fsinsd Excel Discussion (Misc queries) 4 March 15th 06 09:38 AM


All times are GMT +1. The time now is 06:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"