Counta & Countifs in VBA

Danfrancozola

New Member
Joined
Sep 1, 2014
Messages
19
Hello all,

I love using excel but really struggle with VBA - very hard to teach yourself - I am in the process of it.

Anyway, would anyone please be able to re-write the below formulas into VBA so I can assign and run them all with one button click.

Also can you please let me know the best place to find the info to continue my learning.

=COUNTA(Deviations!$F$8:$F$2200)
=COUNTIFS(Deviations!$J$8:$J$2100,"<16",Deviations!$F$8:$F$2100,"<>")
=COUNTIFS(Deviations!$J$8:$J$2100,"<25",Deviations!$F$8:$F$2100,"<>")-J11
=J10-J11-J12

Thank you so much in advance, this has been driving me crazy for days no so thought I should ask for some help!!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
For the first I have managed to come up with this that seems to work, no idea what to do next though.

Sub Example_MONDAY1()

Dim rng_1 As Range
Dim op_cell As Range
Set rng_1 = Range("Deviations!F8:F2200")
Set op_cell = Range("H10")
op_cell = WorksheetFunction.CountA(rng_1)

End Sub
 
Upvote 0
How about
VBA Code:
op_cell.Offset(, 1) = Application.CountIfs(rng_1.Offset(, 4), "<16", rng_1, "<>")
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,184
Members
448,949
Latest member
keycalinc

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