Solved

VBA Excel 2000 - Array formula value to variable

Posted on 2011-02-18
2
403 Views
Last Modified: 2012-05-11
Dear Experts,

Could you please advise how to assign an array formula to a variable?

The attached small code works fine, but I would like if the NumPivotCat would store the formula result without writing it to any cell

thanks,


Sub CountCategories()
Dim NumPivotCat As Long
Worksheets("Sheet1").Range("C2").FormulaArray = "=SUM(IF(FREQUENCY(IF(LEN(A1:A11)>0,MATCH(A1:A11,A1:A11,0),""""), IF(LEN(A1:A11)>0,MATCH(A1:A11,A1:A11,0),""""))>0,1))+(COUNTIF(A1:A11,"""")>0)"
End Sub

Open in new window

0
Comment
Question by:csehz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 34925443
Try:
Sub CountCategories()
Dim NumPivotCat As Long
NumPivotCat  = Evaluate("SUM(IF(FREQUENCY(IF(LEN(A1:A11)>0,MATCH(A1:A11,A1:A11,0),""""), IF(LEN(A1:A11)>0,MATCH(A1:A11,A1:A11,0),""""))>0,1))+(COUNTIF(A1:A11,"""")>0)")
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:csehz
ID: 34925460
I hoped that you will answer and can give the points. As the whole formula I got from you, thanks very much it works :-)
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question