Forum Discussion
Status Bar Count from a Macro
- Jun 01, 2020Your very welcome, glad it helped. Please mark as answered to close the thread.
Bruce1951 I'm a little confused on your question. Are you saying your macro is creating the text in the status bar or that your macro is doing something like applying a filter which results in Excel presenting that text in the status bar and you would rather have that text in a cell? I'm thinking you mean the later and it would be easier to just do a count of the number of rows 'found' on the sheet. Maybe include a little more details and the sheet itself.
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
- mtarlerJun 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