Convert formula to VBA

rdw72777

Well-known Member
Joined
Apr 5, 2005
Messages
723
How would i convert the following formula (that works) to VBA, assuming row 3 is a VBA variable called myrow, column C is a variable (numeric) called col1 and column h is is a variable (numeric) called col2:

Code:
=SUM(IF(FREQUENCY(C3:H3,C3:H3)>0,1))

I tried:

Code:
Evaluate("=SUM(IF(FREQUENCY(" & Range(Cells(myrow, col1), Cells(myrow, col2)) & "," & Range(Cells(myrow, col1), Cells(myrow, col2)) & ")>0,1))")
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Perfect it worked. I wish I never forgot these types of things, far more annoying than the hard stuff.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

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