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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
David

Couldn't this be done with a CountIf?

Which could be accessed in code via Application.WorksheetFunction.
 
Upvote 0

David0079

New Member
Joined
Jul 26, 2007
Messages
44
Dim myRange As Range
Set myRange = Worksheets("Actions").Range("A4:A500")
answer = Application.WorksheetFunction.CountIf(CONTAINS TEXT?)
MsgBox & "of" answer


????
 
Upvote 0

Paddy1979

Well-known Member
Joined
Sep 23, 2005
Messages
608
Like this david

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

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
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

David0079

New Member
Joined
Jul 26, 2007
Messages
44
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,191,517
Messages
5,987,063
Members
440,074
Latest member
Emmanuelian

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
Top