Solved

VBA Excel 2000 - Array formula value to variable

Posted on 2011-02-18
2
382 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel-Find duplicates that ONLY have paticular criteria in another column 21 34
excel 2016 program to loop through scripts 6 32
Excel Formula 5 43
Excel User Form VBA Help 18 29
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

816 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now