View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
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)