+ Reply to Thread
Results 1 to 12 of 12

VBA How to add a new line in a MsgBox message

  1. #1
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    VBA How to add a new line in a MsgBox message

    How do you add a new line in a MsgBox message ?

    Trying to put these 3 lines into one MsgBox message:
    Please Login or Register  to view this content.
    This works:
    Please Login or Register  to view this content.
    This doesn't:
    Please Login or Register  to view this content.
    The whole code:
    Please Login or Register  to view this content.
    Thank you!
    Attached Files Attached Files
    Last edited by briskie; 04-19-2024 at 04:17 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,617

    Re: VBA How to add a new line in a MsgBox message

    What's , , "" supposed to do?
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA How to add a new line in a MsgBox message

    I have no idea. I got it somewhere, now I'm trying to find the source again.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,490

    Re: VBA How to add a new line in a MsgBox message

    Just take it out.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA How to add a new line in a MsgBox message



    Thank you!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,490

    Re: VBA How to add a new line in a MsgBox message

    You're welcome. Thanks for the rep.

  7. #7
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA How to add a new line in a MsgBox message

    Quote Originally Posted by protonLeah View Post
    What's , , "" supposed to do?
    It does this:
    Attached Images Attached Images

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,490

    Re: VBA How to add a new line in a MsgBox message

    Ah. It's to clear the default MsgBox title and it is only added at the end.

    MsgBox (prompt, [ buttons, ] [ title, ] [ helpfile, context ])

    Your code is building the prompt.

  9. #9
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA How to add a new line in a MsgBox message

    Ah, ok. Thanks for the insight.

  10. #10
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA How to add a new line in a MsgBox message

    Oh, ok. So the title is used as the message text? That's why all three lines are bold?

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,490

    Re: VBA How to add a new line in a MsgBox message

    I was not aware of that effect. As often as not, people don't bother with a MsgBox title. That is, they leave it out completely. In this case, the default title is replaced by a null value. What you see is obviously what you get when you do that. Maybe just a quirk.

  12. #12
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA How to add a new line in a MsgBox message

    Understand. Yes, I'm thinking of ditching the title too. And it's a bit easier to read.
    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Suppressing a System Message (or force answer as YES)
    By hans302 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-01-2020, 09:23 AM
  2. MsgBox Message - Where Is It Coming From ??
    By Logit in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-05-2019, 05:36 PM
  3. Force msgbox to always appear at top of window stack
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-12-2012, 06:13 AM
  4. Force MsgBox to the front
    By JimmyA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2008, 01:08 PM
  5. MsgBox-center the message on a msgbox
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2007, 06:48 AM
  6. Force a Message Box to close unanswered
    By jennie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2005, 06:05 AM
  7. [SOLVED] concatenate, force new line
    By JohnT in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2005, 01:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1