Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Align in MSGBOX (EXCEL 97/2000)

    Can I align texts in a standard (EXCEL) VBA MSGBOX?

    E.g.
    This is line 1 : Test
    And this could be line 2 : Test

    I'd like the ':' to be aligned...

    Erik Jan

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Align in MSGBOX (EXCEL 97/2000)

    I think your best option would be to roll your own message box by way of a userform. That way in th example you gave you could have 2 labels for each line, and align the labels and hence the values. The problem with the message box is I think the font used cannot be changed except by changing some settings in your display prferences. It would need to be changed to a monospaced font to get the alignment you are looking for. And that would most probably be unsuitable for other dispaly items, like menus etc.

    Andrew C

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Align in MSGBOX (EXCEL 97/2000)

    Andrew,

    Guess I was afraid of that (that's why I explicitly mentioned 'standard' messagebox)... I had hoped that with Tab() and/or Chr$(7) or so some things would have been possible...

    Thanks for your reply!

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Align in MSGBOX (EXCEL 97/2000)

    Hi,
    You can as long as you have the same characters after the colon - e.g.
    msgbox "Line 1 : Test" & vbcrlf & "This is line 2 : Test", _
    vbmsgboxright + vbyesno, "Test align"
    You can also use vbTab in a msgbox which may help you to align the message.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Align in MSGBOX (EXCEL 97/2000)

    Thanks Rory,

    VbTab did help!

    Erik Jan

Posting Permissions

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