Trying to Write Excel formula in VBA

nirvehex

Well-known Member
Joined
Jul 27, 2011
Messages
505
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to write an excel formula in VBA which gives me a unique count of a certain column. However, I'm getting an #N/A when I write it in VBA.

Any thoughts?

Here's the part that's giving the #N/A in the code:

Code:
.Range("B" & NumberofRows + 4).Formula = "=SUM(IF(FREQUENCY(MATCH($B$3:$B$" & NumberofRows & ",$B$3:$B$" & NumberofRows & "),MATCH($B$3:$B$" & NumberofRows & ",$B$3:$B$" & NumberofRows & ",0))>0,1))"

Thanks!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
It looks like you should be using Formulaarray and not Formula.
 
Upvote 0
Thanks Rory, unfortunately using FormulaArray produced the same #N/A.
 
Upvote 0
It looks like you are missing a ,0 from the end of your first MATCH function.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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