VBA Code for updating status bar at the bottom + automatic refresh

theguyIsHere

New Member
Joined
Oct 2, 2013
Messages
19
Office Version
  1. 2019
Platform
  1. MacOS
I am using the code below to show me the largest number in column B in the status bar.

VBA Code:
Sub Return_highest_number()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Gantt table")

'return highest number in a range
Application.StatusBar = "Next ID = " & Application.WorksheetFunction.Max(ws.Range("B2:B99"))

End Sub

I would be grateful if you can guide me on:

1 - How do I add +1 to the max number
2 - The status bar automatically refreshes itself with the next highest number when a user enters a maximum number

Thank you
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
For step 2 above. in other words, the status bar should refresh any time an entry is made in column B.

Thank you in advance
 
Upvote 0
I am using the code below to show me the largest number in column B in the status bar.

VBA Code:
Sub Return_highest_number()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Gantt table")

'return highest number in a range
Application.StatusBar = "Next ID = " & Application.WorksheetFunction.Max(ws.Range("B2:B99"))

End Sub

I would be grateful if you can guide me on:

1 - How do I add +1 to the max number

Simplest answer to 1) would be application.StatusBar = "Next ID = " & Application.WorksheetFunction.Max(ws.Range("B2:B99")) + 1

For step 2 above. in other words, the status bar should refresh any time an entry is made in column B.

Probably a worksheet change event is what you need.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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