Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Counting cells using EVALUATE

I'm trying to calculate and return a count based on a range and am having
trouble getting it right. I am counting retail store numbers that may be
typed in the range. I then use the count in other place in my macro.

Non-working code:
funcRange = "ActiveSheet.Cells(""DX1:IV1"")"
funcName = "=COUNTA"
funcNameRange = funcName & "(" & funcRange & ")"
mStoreCount = Evaluate(funcNameRange)

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Counting cells using EVALUATE

Sorry. I figured it out. Thanks!

funcRange = "'" & ActiveSheet.Name & "'!DX1:IV1"
funcName = "=COUNTA"
funcNameRange = funcRange & "(" & funcName & ")"
mStrCount = Evaluate(funcNameRange )


"BB Ivan" wrote:

I'm trying to calculate and return a count based on a range and am having
trouble getting it right. I am counting retail store numbers that may be
typed in the range. I then use the count in other place in my macro.

Non-working code:
funcRange = "ActiveSheet.Cells(""DX1:IV1"")"
funcName = "=COUNTA"
funcNameRange = funcName & "(" & funcRange & ")"
mStoreCount = Evaluate(funcNameRange)

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default Counting cells using EVALUATE

Alternatively:

mStrCount = Application.CountA(ActiveSheet.Range("DX1:IV1"))

In article ,
BB Ivan wrote:

Sorry. I figured it out. Thanks!

funcRange = "'" & ActiveSheet.Name & "'!DX1:IV1"
funcName = "=COUNTA"
funcNameRange = funcRange & "(" & funcName & ")"
mStrCount = Evaluate(funcNameRange )

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Counting cells using EVALUATE

Better and simpler! Thanks

"JE McGimpsey" wrote:

Alternatively:

mStrCount = Application.CountA(ActiveSheet.Range("DX1:IV1"))

In article ,
BB Ivan wrote:

Sorry. I figured it out. Thanks!

funcRange = "'" & ActiveSheet.Name & "'!DX1:IV1"
funcName = "=COUNTA"
funcNameRange = funcRange & "(" & funcName & ")"
mStrCount = Evaluate(funcNameRange )


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Counting cells using EVALUATE

Sub dural()
funcRange = "DX1:IV1"
funcName = "=COUNTA"
funcNameRange = funcName & "(" & funcRange & ")"
MsgBox (funcNameRange)
mStoreCount = Evaluate(funcNameRange)
MsgBox (mStoreCount)
End Sub


If you use COUNTA directly in VBA, the argument must be a Range. If you use
COUNTA within EVALUATE, the whole thing is just a String.
--
Gary''s Student - gsnu200829


"BB Ivan" wrote:

I'm trying to calculate and return a count based on a range and am having
trouble getting it right. I am counting retail store numbers that may be
typed in the range. I then use the count in other place in my macro.

Non-working code:
funcRange = "ActiveSheet.Cells(""DX1:IV1"")"
funcName = "=COUNTA"
funcNameRange = funcName & "(" & funcRange & ")"
mStoreCount = Evaluate(funcNameRange)



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Counting cells using EVALUATE

Thanks so much for your help!

"Gary''s Student" wrote:

Sub dural()
funcRange = "DX1:IV1"
funcName = "=COUNTA"
funcNameRange = funcName & "(" & funcRange & ")"
MsgBox (funcNameRange)
mStoreCount = Evaluate(funcNameRange)
MsgBox (mStoreCount)
End Sub


If you use COUNTA directly in VBA, the argument must be a Range. If you use
COUNTA within EVALUATE, the whole thing is just a String.
--
Gary''s Student - gsnu200829


"BB Ivan" wrote:

I'm trying to calculate and return a count based on a range and am having
trouble getting it right. I am counting retail store numbers that may be
typed in the range. I then use the count in other place in my macro.

Non-working code:
funcRange = "ActiveSheet.Cells(""DX1:IV1"")"
funcName = "=COUNTA"
funcNameRange = funcName & "(" & funcRange & ")"
mStoreCount = Evaluate(funcNameRange)

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
=EVALUATE("{ to work in a range of cells Fin Fang Foom Excel Worksheet Functions 8 May 9th 07 11:33 PM
How do I evaluate a row of cells for a character in each cell? TwoDot Excel Worksheet Functions 2 September 22nd 06 12:53 PM
Function evaluate multiple cells and return 1st one w/a value Dan Shoemaker Excel Discussion (Misc queries) 1 August 27th 06 02:46 AM
evaluate two cells and calculate based on criteria galiant Excel Worksheet Functions 6 July 10th 06 04:21 PM
Using AND function to evaluate cells murphyslaw18 Excel Worksheet Functions 1 January 13th 06 12:38 AM


All times are GMT +1. The time now is 12:01 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"