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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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