SOLVED

Status Bar Count from a Macro

%3CLINGO-SUB%20id%3D%22lingo-sub-1430055%22%20slang%3D%22en-US%22%3EStatus%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1430055%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20created%20a%20macro%20in%20Excel%202019%20that%20presents%20the%20answer%20(Count)%20in%20the%20status%20bar%20at%20the%20lower%20left%20corner%20of%20the%20spreadsheet%2C%20(example%2024%20of%20145%20records%20found).%20The%20answer%20is%20correct.%20I%20would%20like%20to%20take%20that%20answer%2Fcount%20and%20place%20it%20(just%20the%20number%20%2224%22)%20in%20a%20spreadsheet%20cell%20rather%20than%20writing%20it%20down%20on%20a%20piece%20of%20paper%20and%20then%20typing%20it%20into%20the%20cell.%20How%20do%20I%20do%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EBruce%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1430055%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1430331%22%20slang%3D%22en-US%22%3ERe%3A%20Status%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1430331%22%20slang%3D%22en-US%22%3EName%20a%20cell%20as%20%22ResultCell%22%20then%20lets%20say%20the%20count%20value%20created%20in%20you%20macro%20routine%20is%20called%20FoundCount%20then%20add%20a%20line%20of%20code%20at%20the%20end%20saying%20Range(%22ResultCell%22).value%20%3D%20FoundCount%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431123%22%20slang%3D%22en-US%22%3ERe%3A%20Status%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431123%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Wyn%2C%3C%2FP%3E%3CP%3EThanks%20for%20the%20info.%20Unfortunately%20I%20am%20not%20knowledgeable%20enough%20to%20do%20what%20you%20are%20suggesting.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431285%22%20slang%3D%22en-US%22%3ERe%3A%20Status%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431285%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F684932%22%20target%3D%22_blank%22%3E%40Bruce1951%3C%2FA%3E%26nbsp%3B%20I'm%20a%20little%20confused%20on%20your%20question.%26nbsp%3B%20Are%20you%20saying%20your%20macro%20is%20creating%20the%20text%20in%20the%20status%20bar%20or%20that%20your%20macro%20is%20doing%20something%20like%20applying%20a%20filter%20which%20results%20in%20Excel%20presenting%20that%20text%20in%20the%20status%20bar%20and%20you%20would%20rather%20have%20that%20text%20in%20a%20cell%3F%26nbsp%3B%20I'm%20thinking%20you%20mean%20the%20later%20and%20it%20would%20be%20easier%20to%20just%20do%20a%20count%20of%20the%20number%20of%20rows%20'found'%20on%20the%20sheet.%26nbsp%3B%20Maybe%20include%20a%20little%20more%20details%20and%20the%20sheet%20itself.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431332%22%20slang%3D%22en-US%22%3ERe%3A%20Status%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431332%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20latter%20is%20correct%20but%20I%20have%20several%20%22Counts%22%20of%20specific%20numbers%20in%20a%20column%20and%20just%20trying%20to%20create%20a%20quicker%2Feasier%20method%20for%20transferring%20the%20Status%20Line%20answers%20of%20the%20%22Count%22%20by%20having%20it%20show%20up%20in%20cells%20rather%20than%20on%20the%20status%20line%20one%20at%20a%20time.%20I%20have%20Macros%20ctrl%2B(a-j)%20and%20want%20the%20Count%20to%20show%20up%20in%20cells%20so%20I%20can%20then%20use%20a%20macro%20to%20transfer%20the%20answers%20to%20a%20MSWord%20document%20table.%26nbsp%3B%20I%20have%20attached%20the%20macro%20below.%20Thanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431412%22%20slang%3D%22en-US%22%3ERe%3A%20Status%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431412%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F684932%22%20target%3D%22_blank%22%3E%40Bruce1951%3C%2FA%3E%26nbsp%3B%20I%20think%20what%20you%20are%20looking%20for%20is%20how%20to%20use%20a%20function%20like%20%22countif%22%20in%20VBA%20and%20those%20are%20all%20included%20in%20%22WorksheetFunction%22%20so%20WorksheetFunction.Countif(%E2%80%A6)%20and%20then%20you%20can%20assign%20that%20to%20whatever%20cell%20you%20like.%3C%2FP%3E%3CP%3ESo%20your%20first%20macro%20could%20look%20like%20this%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3ESub%20CriteriaScore1()%0A'%0A'%20CriteriaScore1%20Macro%0A'%0A'%20Keyboard%20Shortcut%3A%20Ctrl%2Bb%0A'%0A%20%20%20%20Selection.AutoFilter%0A%20%20%20%20ActiveSheet.Range(%22%24A%241%3A%24O%24146%22).AutoFilter%20Field%3A%3D3%2C%20Criteria1%3A%3D%221%22%0A%20%20%20%20ActiveSheet.Range(%22%24P%241%22)%3Dworksheetfunction.countif(ActiveSheet.Range(%22%24C%241%3A%24C%24146%22)%2C%20%221%22)%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431455%22%20slang%3D%22en-US%22%3ERe%3A%20Status%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431455%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EVery%20cool.%20It%20worked.%20And%20so%20easy%20now%20that%20you%20showed%20me%20what%20to%20write%20into%20the%20macro%20text.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20so%20much%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBruce%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431473%22%20slang%3D%22en-US%22%3ERe%3A%20Status%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431473%22%20slang%3D%22en-US%22%3EYour%20very%20welcome%2C%20glad%20it%20helped.%20Please%20mark%20as%20answered%20to%20close%20the%20thread.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431491%22%20slang%3D%22en-US%22%3ERe%3A%20Status%20Bar%20Count%20from%20a%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431491%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnswered.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

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 like to take that answer/count and place it (just the number "24") in a spreadsheet cell rather than writing it down on a piece of paper and then typing it into the cell. How do I do this?

 

Thanks,

Bruce

8 Replies
Name a cell as "ResultCell" then lets say the count value created in you macro routine is called FoundCount then add a line of code at the end saying Range("ResultCell").value = FoundCount

@Wyn Hopkins 

 

Hi Wyn,

Thanks for the info. Unfortunately I am not knowledgeable enough to do what you are suggesting.

 

@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.

@mtarler

 

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

@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

 

@mtarler 

 

Very cool. It worked. And so easy now that you showed me what to write into the macro text.

 

Thanks so much,

 

Bruce

Best Response confirmed by Bruce1951 (Occasional Contributor)
Solution
Your very welcome, glad it helped. Please mark as answered to close the thread.

@mtarler 

 

Answered.