Customizing Message box using excel VBA

pkdash83

New Member
Joined
Apr 28, 2014
Messages
12
Hi All,

I've a message to be displayed on a button click. The below macro is assigned.

Sub getmsg()
MsgBox "The store " & Range("C7").Value & " is from " & Range("I3") & " and the sales is " & Range("C9")
End Sub


What I need is if the sales>=40000 the sales value displayed shpuld be green else red.

Is there any way I can achieve it? Or can I use any other control to do it?

Please help.

Thanks,
Prasanna
 

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.
Hi pkdash83,

I do not believe it would be possible to change part of the Prompt text's color in any circumstance. Possibly you might be able to change all of the prompt text's color with API, but IMO, it would be a hassle and not worth it at all.

Even with a Userform made to look like (and act like) a message box (which is what I would try), changing part of the text's color would require layered controls, and some size-to-fit considerations for locating at least one label (presumably).

Are you comfortable with userforms, and if so, would you want to give that a go?

Mark
 
Upvote 0
GTO, nice, relatively straightforward solution. If you separate the statement into two lines on the UserForm you only need 3 label controls, and only one of these needs positioning and color.
 
Upvote 0
Thanks for all the responses. I was thinking of a way-is it possible to store the sales part in a variable and display it dynamically?
 
Upvote 0

Forum statistics

Threads
1,215,336
Messages
6,124,338
Members
449,155
Latest member
ravioli44

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