Consulting

Results 1 to 8 of 8

Thread: change word spacing in a messagbox

  1. #1

    change word spacing in a messagbox

    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

  2. #2
    VBAX Mentor
    Joined
    Apr 2009
    Location
    Kingsbury
    Posts
    423
    Location
    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.

  3. #3
    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

  4. #4
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Hi selfteaching!
    Not sure what you want.
    MsgBox "     Last Check Number     " & Range("k1")

  5. #5
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    You didn't try either:

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

  6. #6
    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

  7. #7
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    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
    Last edited by 大灰狼1976; 03-21-2019 at 12:43 AM.

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,058
    Location
    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/...0-8bb604e6c6f4
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •