Format VBA expression with comma separator

Ironman

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

I have the following 2 message boxes
VBA Code:
If 1000 - A <= 100 Then MsgBox 1000 - A & " miles to go until you hit " & Range("CG375").Value + 1000 - A
If A > 0 And A <= 10 Then MsgBox "Congratulations! You have now run over " & Range("CG375").Value - A & " miles"
I've tried but I'm unable to amend the code in each line beyond the dot to create a comma separator for the thousands.

Help appreciated!

Thank you.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Use the Format function - eg Format(expression, "#,##0")
 
Upvote 0
Solution
Sorted, thanks
VBA Code:
If 1000 - A <= 100 Then MsgBox 1000 - A & " miles to go until you reach " & Format(Range("CG375").Value + 1000 - A, "#,##0"), vbInformation, "1,000 Mile Countdown"
If A > 0 And A <= 10 Then MsgBox "Congratulations! You have now run over " & Format(Range("CG375").Value - A, "#,##0") & " miles", vbInformation, "1,000 Mile Countdown"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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