Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default VBA Format for a Range Name Used in the Sum Function

I am trying to run some VBA code that I would use Range names rather than a
specific range, ie Data!M3:M223.

MsgBox Evaluate("SUM( Data!M3:M223 )") will work, but when I change it to
include the Range name representing Data!M3:M223, it does not. Can anyone
help to figure out what I'm doing wrong. Thanks in advance.


Dim mTimeCriteria As String
Dim mPosition As String
Dim mFormula As String
Dim mQuestion1Range As Range


mTimeCriteria = "First day of employment (Time 1)"
mPosition = "Registered Nurse"
mPositionRange = Worksheets("Data").Range("DataPosition")
Set mTimeRange = Worksheets("Data").Range("DataTime")
Set mQuestion1Range = Worksheets("Data").Range("DataQuestion1")


MsgBox Evaluate("SUM( mQuestion1Range )")

  #2   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default VBA Format for a Range Name Used in the Sum Function

MsgBox Evaluate(Application.WorksheetFunction.Sum(mQuesti on1Range))

Dan

"DogLover" wrote:

I am trying to run some VBA code that I would use Range names rather than a
specific range, ie Data!M3:M223.

MsgBox Evaluate("SUM( Data!M3:M223 )") will work, but when I change it to
include the Range name representing Data!M3:M223, it does not. Can anyone
help to figure out what I'm doing wrong. Thanks in advance.


Dim mTimeCriteria As String
Dim mPosition As String
Dim mFormula As String
Dim mQuestion1Range As Range


mTimeCriteria = "First day of employment (Time 1)"
mPosition = "Registered Nurse"
mPositionRange = Worksheets("Data").Range("DataPosition")
Set mTimeRange = Worksheets("Data").Range("DataTime")
Set mQuestion1Range = Worksheets("Data").Range("DataQuestion1")


MsgBox Evaluate("SUM( mQuestion1Range )")

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default VBA Format for a Range Name Used in the Sum Function

Thanks Dan. It works now!

"Dan" wrote:

MsgBox Evaluate(Application.WorksheetFunction.Sum(mQuesti on1Range))

Dan

"DogLover" wrote:

I am trying to run some VBA code that I would use Range names rather than a
specific range, ie Data!M3:M223.

MsgBox Evaluate("SUM( Data!M3:M223 )") will work, but when I change it to
include the Range name representing Data!M3:M223, it does not. Can anyone
help to figure out what I'm doing wrong. Thanks in advance.


Dim mTimeCriteria As String
Dim mPosition As String
Dim mFormula As String
Dim mQuestion1Range As Range


mTimeCriteria = "First day of employment (Time 1)"
mPosition = "Registered Nurse"
mPositionRange = Worksheets("Data").Range("DataPosition")
Set mTimeRange = Worksheets("Data").Range("DataTime")
Set mQuestion1Range = Worksheets("Data").Range("DataQuestion1")


MsgBox Evaluate("SUM( mQuestion1Range )")

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default VBA Format for a Range Name Used in the Sum Function

Expanding functionality now. I am going to want to use multiple criteria and
am just testing how to use the SumProduct in VBA before I expand to multiple
Criteria.
I seem to have my format off and wondered if anyone can see what is wrong.

MsgBox Evaluate(Application.WorksheetFunction.SumProduct( (mTimeRange =
"First day of employment (Time 1)") * (mQuestion1Range)))




"Dan" wrote:

MsgBox Evaluate(Application.WorksheetFunction.Sum(mQuesti on1Range))

Dan

"DogLover" wrote:

I am trying to run some VBA code that I would use Range names rather than a
specific range, ie Data!M3:M223.

MsgBox Evaluate("SUM( Data!M3:M223 )") will work, but when I change it to
include the Range name representing Data!M3:M223, it does not. Can anyone
help to figure out what I'm doing wrong. Thanks in advance.


Dim mTimeCriteria As String
Dim mPosition As String
Dim mFormula As String
Dim mQuestion1Range As Range


mTimeCriteria = "First day of employment (Time 1)"
mPosition = "Registered Nurse"
mPositionRange = Worksheets("Data").Range("DataPosition")
Set mTimeRange = Worksheets("Data").Range("DataTime")
Set mQuestion1Range = Worksheets("Data").Range("DataQuestion1")


MsgBox Evaluate("SUM( mQuestion1Range )")

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
Find Last cell in Range when range is date format default105 Excel Discussion (Misc queries) 5 July 7th 09 03:11 PM
Cond. Format Data Bars of range based on values of another range alexmo Excel Worksheet Functions 4 January 16th 09 04:03 AM
Range to echo format (hilite/fontcolors) of sister range? Schooner Excel Worksheet Functions 2 February 15th 08 07:20 AM
how do i format a cell based on format of a range of cells? Chris Hardick Excel Discussion (Misc queries) 2 April 3rd 06 08:54 AM
Format when sending a range as parameter to a custom function George Furnell Excel Programming 2 December 1st 05 05:22 PM


All times are GMT +1. The time now is 04:41 AM.

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"