Forum Discussion
Bruce1951
May 31, 2020Copper Contributor
Status Bar Count from a Macro
I have created a macro in Excel 2019 that presents the answer (Count) in the status bar at the lower left corner of the spreadsheet, (example 24 of 145 records found). The answer is correct. I would ...
- Jun 01, 2020Your very welcome, glad it helped. Please mark as answered to close the thread.
Bruce1951
Jun 01, 2020Copper Contributor
The latter is correct but I have several "Counts" of specific numbers in a column and just trying to create a quicker/easier method for transferring the Status Line answers of the "Count" by having it show up in cells rather than on the status line one at a time. I have Macros ctrl+(a-j) and want the Count to show up in cells so I can then use a macro to transfer the answers to a MSWord document table. I have attached the macro below. Thanks
mtarler
Jun 01, 2020Silver Contributor
Bruce1951 I think what you are looking for is how to use a function like "countif" in VBA and those are all included in "WorksheetFunction" so WorksheetFunction.Countif(…) and then you can assign that to whatever cell you like.
So your first macro could look like this:
Sub CriteriaScore1()
'
' CriteriaScore1 Macro
'
' Keyboard Shortcut: Ctrl+b
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$O$146").AutoFilter Field:=3, Criteria1:="1"
ActiveSheet.Range("$P$1")=worksheetfunction.countif(ActiveSheet.Range("$C$1:$C$146"), "1")
End Sub