MsgBox with count

David0079

New Member
Joined
Jul 26, 2007
Messages
44
Hi,
I've created this MsgBox to show the results of a filter. Sadly my knowledge will only take me as far as counting all the rows up from the bottom including the blank ones! I have a header in row 3 so would like to count all only cells with information in them from cell A4 down to the last, could anyone help tweak my code to do this. Tank you all!

Code:
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
MsgBox rng.Columns(1). _
   SpecialCells(xlCellTypeVisible).Count - 1 _
   & " of " & Worksheets("jobs").Cells(Rows.Count, 1).End(xlUp).Row + 1 & " jobs are still unfinished and have passed their deadline!", vbCritical, "Uh oooh"
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
David

Couldn't this be done with a CountIf?

Which could be accessed in code via Application.WorksheetFunction.
 
Upvote 0
Dim myRange As Range
Set myRange = Worksheets("Actions").Range("A4:A500")
answer = Application.WorksheetFunction.CountIf(CONTAINS TEXT?)
MsgBox & "of" answer


????
 
Upvote 0
Like this david

Code:
X = Application.WorksheetFunction.CountA(Range("A:A")) - 1
Z = Application.WorksheetFunction.CountA(Range("jobs!A:A")) + 1
 
Upvote 0
david

The syntax would depend on what you are actually trying to count.

And we don't know what that is because we haven't seen any data and don't know what/how you are filtering.:)
 
Upvote 0
Yessss sorted! Thanks VERY much fellas, used this ....

Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
X = Application.WorksheetFunction.CountA(Range("A1:A500"))
MsgBox rng.Columns(1). _
SpecialCells(xlCellTypeVisible).Count - 1 & " of " & X & " Jobs are still unfinished but have passed their deadline!", vbCritical, "Uh oooh"

You guys are fantastic!
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,767
Members
449,049
Latest member
greyangel23

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