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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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