PDA

View Full Version : [SOLVED] change word spacing in a messagbox



selfteaching
03-18-2019, 09:41 AM
Hi
I'm using the following macro to show what is in a cell
How would I add a couple of spaces between the last word and the number?
And is there a way to change the font?

Sub lastnumber()
MsgBox " Last Check Number" & Range("k1")
End Sub




mike

Rob342
03-18-2019, 12:38 PM
Hi Mike



Sub lastnumber()
MsgBox " Last Check Number" & " " & Range("k1")
End Sub

Changing the font is not worth the effort cause you will have to change system settings
could use a userForm then you change what you want.

selfteaching
03-18-2019, 03:37 PM
thanks Rob342

That's the one thing I didn't try.

Thank you

I diffidently don't want to try to change any system settings.


Mike

大灰狼1976
03-18-2019, 06:38 PM
Hi selfteaching!
Not sure what you want.

MsgBox " Last Check Number " & Range("k1")

snb
03-20-2019, 07:33 AM
You didn't try either:


Sub M_snb()
MsgBox space(10)& "Last Check Number" & Space(15)& Range("k1")
End Sub

selfteaching
03-20-2019, 09:00 AM
Hi snb
I tried adding spaces btw the last" and &
I aslo tried adding spaces btw & and Range
I didn't think to add spaces after the last " and add another one
I didn't see 大灰狼1976 answer till after I thanked Rob342
After I read 大灰狼1976 answer, Which I tried before, I noticed that I didn't mark the thread solved.
I then forgot to thank 大灰狼1976 for responding

I also like your way...which I just tried :)
Sorry if I offended

mike

大灰狼1976
03-21-2019, 12:22 AM
And you didn't try either::)

MsgBox String(10, " ") & "Last Check Number" & String(15, " ") & Range("k1")
MsgBox Application.Rept(" ", 10) & "Last Check Number" & Application.Rept(" ", 15) & Range("k1")
MsgBox Space(10) & "Last Check Number" & Format(Range("k1"), " 0") 'if cell K1 is an integer

Aussiebear
03-21-2019, 01:34 AM
A quick search has shown that HansV an Excel MVP has suggested that the font and style of text in a messagebox is set by your excel preferences, however he did suggest that you might try creating your own dialogue box as an alternative See here https://answers.microsoft.com/en-us/msoffice/forum/all/excel-vba-change-font-style-in-msgbox/30377d59-1e08-4948-8060-8bb604e6c6f4