CountIf Usage Across Two Worksheets

Tuffman

New Member
Joined
May 31, 2012
Messages
48
Office Version
  1. 2016
Platform
  1. Windows
I can't get this code to run, I keep getting an error that says "Compile error: Invalid qualifier". I'm wanting to count the number of blue cars on the "Cars" worksheet in column J from rows 45-70. Then have that number shown in cell C10 on the Summary worksheet. Can someone help me understand why this isn't running?


Worksheets("Summary").Range("C10") = Worksheets("Cars").WorksheetFunction.CountIf(Range("J45:J70"), "Blue")
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Your sheet reference needs to go before the range reference, i.e.
VBA Code:
    Worksheets("Summary").Range("C10") = WorksheetFunction.CountIf(Worksheets("Cars").Range("J45:J70"), "Blue")
 
Upvote 0
Solution
Your sheet reference needs to go before the range reference, i.e.
VBA Code:
    Worksheets("Summary").Range("C10") = WorksheetFunction.CountIf(Worksheets("Cars").Range("J45:J70"), "Blue")
Thank you Joe4, that worked perfectly!
 
Upvote 0
You are welcome.

Please note: When marking a post as the solution, please mark the original post containing the solution (and not your own post indicated that another post is the solution).
I have updated this one for you.
 
Upvote 0

Forum statistics

Threads
1,221,537
Messages
6,160,400
Members
451,645
Latest member
hglymph

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