Can a message box title be coded?

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

I've looked around online and I can only see text strings for the message box title. I was wondering if it's possible to code it e.g.
VBA Code:
vbInformation, "Format(Sheets("Daily Tracking").Range("CG375").Value + 1000 - A, "#,##0") & " miles" Countdown"
When I tried that, it errored "syntax error" so I'm guessing the answer is no?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
First build it in a string variable. Then use that string variable in your code.
That also makes it east to verify you have created the string correctly (the end of yours looks a little off).
VBA Code:
Dim ttl As String
ttl = "This is a test"
MsgBox "How are you?", vbInformation, ttl
 
Upvote 0
Ah great, thanks Joe, I'll give that a go.
 
Upvote 0
Hi Joe

I've tested your code out and your method works great as below:
VBA Code:
ttl = Format(Sheets("Daily Tracking").Range("CG375").Value + 1000, "#,##0") & " Mile Countdown"

But could I just have a little help with the final bit please, which I just can't get right - it's this part:
VBA Code:
Range("CG375").Value + 1000, "#,##0"
The value of Cell CG375 is 27,903 and the above code shows the value as 28,903, which isn't what I want. All I'm after is for the value of CG375 in the the above code to be rounded up to the nearest whole 1,000 i.e. until the value of CG375 reaches 28,001 I need it to show 28,000 and after that 29,000 and so on.

Thank you!
 
Last edited:
Upvote 0
Try this:
VBA Code:
ttl = Application.WorksheetFunction.RoundUp(Sheets("Daily Tracking").Range("CG375"), -3) & " Mile Countdown"
 
Upvote 0
Hey, that's great, thanks a lot Joe - could I just finally please ask if you could include the 1,000 comma separator in the above?

Thanks again!
 
Upvote 0
Hey, that's great, thanks a lot Joe - could I just finally please ask if you could include the 1,000 comma separator in the above?

Thanks again!
That is where you add in the FORMAT function like you had in your original one:
VBA Code:
ttl = Format(Application.WorksheetFunction.RoundUp(Sheets("Daily Tracking").Range("CG375"), -3), "#,##0") & " Mile Countdown"
 
Upvote 0
Solution
Awwww that's brilliant, I don't know why I didn't think of that.

Many thanks for all your help Joe!

Edit: I did try that but I assumed it needed another set of brackets, which is where I went wrong.
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

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