Count Sheets based on Cell Values

SimmonsDeux

New Member
Joined
Dec 29, 2014
Messages
17
Guys,
I have a userform (frmNavigation) with labels that I want to tally up the sheets based on the value of cell b6. This cell will always be one of three values (Cat Parts, Manufacturing, Imports) and I have 3 Labels (Label 9, label 10, label 11) that I would like to display these counts.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
How do you know which total B6 is showing? Cat Pats, Manfc, or Imports?
I manually Entered each cel value. I'm looking for a CountIF equivalent in VBA that counts how many sheets contain "Cat Parts" in cel B6, How many sheets contain "Imports" in B6, and How many sheets contain "Manufacturing" in B6.
 
Upvote 0
Why not just loop through all the sheets within the workbook and check it that way?

Code:
Option Compare Text 'ignore text case
Dim cparts as long
Dim manf as long
Dim impts as long
Dim Current As Worksheet
For Each Current In Worksheets
'cat parts count
if instr(Current.range("B6"), "Parts") then
cparts = cparts + 1
endif
'manf count
if instr(Current.range("B6"), "Manu") then
manf = manf + 1
endif
'impts count
if instr(Current.range("B6"), "Imp") then
impts = impts + 1
endif
next
Me.Label9.caption = cparts
Me.Label10.caption = manf
Me.Label11.caption = impts
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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