Creating Countifs and Averageif Functions in VBA

bowmanbowman

New Member
Joined
Nov 6, 2018
Messages
1
[FONT=&quot]I need help creating a few VBA functions in Excel:[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]First I need to write a function (myCountIfs) that works similar to Excel's in built COUNTIFS function. It returns an integer.[/FONT]

  1. The first is a range that will be used in the calculation (i.e., average)
  2. The first is the 1st range that will be used for the criteria
  3. The second is the string value that the criteria cell values must be
  4. The third is the 2nd range that will be used for the criteria
  5. The fourth is a string value that the criteria cell values must be.
  6. For instance, if the user enters myCountIfs(B2:B10,"student", D2:D10, "boat"), the result should return 2.
[FONT=&quot]
[/FONT]

[FONT=&quot]Then I need to write a function (myAverageIf) that works similar to Excel's in-built AVERAGEIF function works. The function should take in three arguments. It returns a double[/FONT]

  1. The first is a range that will be used in the calculation (i.e., average)
  2. The second is the range that will be used for the criteria
  3. The third is a string value that the criteria cell values must be
  4. For instance, if the user enters myAverageIf(C2:C10, D2:D10, "boat") the resultshould return 1.395.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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