Converting Nested Excel Formula (SUM, IF, FREQUENCY) into VBA

MrcAm

New Member
Joined
Oct 2, 2011
Messages
7
I`m trying to move a formula that I already have working in Excel into VBA. I am trying to add the unique instances of numbers in column E together. The Excel formula is as follows:

=SUM(IF(FREQUENCY(E:E,E:E)>0,1))

I have tried playing around with the worksheetfunction but can`t seem to get it to work correctly. Can someone help me with this? Thank you in advance for trying.
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I think that the easiest way to do this would be to use the formula and convert the results to values

Code:
With Range("A1")
    .Formula = "=SUM(IF(FREQUENCY(E:E,E:E)>0,1))"
    .Value = .Value
End With

Or take a look at the Evaluate method.
 
Upvote 0
I think that the easiest way to do this would be to use the formula and convert the results to values

Code:
With Range("A1")
    .Formula = "=SUM(IF(FREQUENCY(E:E,E:E)>0,1))"
    .Value = .Value
End With
Or take a look at the Evaluate method.

The Evaluate method fits my needs perfectly. Thank you very much for the help.
 
Upvote 0

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top