Results 1 to 12 of 12

VBA How to add a new line in a MsgBox message

Threaded View

  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:
      MsgBox "Shape 1 Name: " & shp1.Name, , ""
      MsgBox "Shape 2 Name: " & shp2.Name, , ""
      MsgBox "Shape 3 Name: " & shp3.Name, , ""
    This works:
      MsgBox "This information is on the first line. " & vbNewLine & _
             "This information is on the 2nd line. " & vbNewLine & _
             "This infornation is on the 3rd line. "
    This doesn't:
      MsgBox "Shape 1 Name: " & shp1.Name, , "" & vbNewLine & _
             "Shape 2 Name: " & shp2.Name, , "" & vbNewLine & _
             "Shape 3 Name: " & shp3.Name, , ""
    The whole code:
    ' Button alpha ALL IPB
    Sub Button_alpha_ALL_IPB()
    
    Dim rng As Range
    Dim shp1 As Shape
    Dim shp2 As Shape
    Dim shp3 As Shape
    Const DIA As Single = 9
    Const LINEWGHT As Single = 1
    
    On Error Resume Next
    Set rng = Application.InputBox(Title:="1/4 Select Shape Range", _
                                   Prompt:="",  _
                                   Type:=8)
      Set shp1 = ActiveSheet.Shapes.AddShape(9, rng.Left + 5, _
                                                rng.Top + ((rng.Height - DIA) / 2), _
                                                DIA, _
                                                DIA)
        With shp1
        .Name = Application.InputBox(Title:="2/4 Enter Name Level 1", _
                                     Default:="_L1", _
                                     Prompt:="",  _
                                     Type:=2)
        .Shadow.Visible = False
        .Fill.Visible = True
        .Fill.ForeColor.RGB = vbGreen
        .Line.Visible = False
        .Line.ForeColor.RGB = vbRed
        .Line.Weight = LINEWGHT
        .Line.Transparency = 0
        End With
      Set shp2 = ActiveSheet.Shapes.AddShape(9, rng.Left + 19, _
                                                rng.Top + ((rng.Height - DIA) / 2), _
                                                DIA, _
                                                DIA)
        With shp2
        .Name = Application.InputBox(Title:="3/4 Enter Name Level 2", _
                                     Default:="_L2", _
                                     Prompt:="",  _
                                     Type:=2)
        .Shadow.Visible = False
        .Fill.Visible = True
        .Fill.ForeColor.RGB = vbGreen
        .Line.Visible = False
        .Line.ForeColor.RGB = vbRed
        .Line.Weight = LINEWGHT
        .Line.Transparency = 0
        End With
      Set shp3 = ActiveSheet.Shapes.AddShape(9, rng.Left + 33, _
                                                rng.Top + ((rng.Height - DIA) / 2), _
                                                DIA, _
                                                DIA)
        With shp3
        .Name = Application.InputBox(Title:="4/4 Enter Name Level 3", _
                                     Default:="_L3", _
                                     Prompt:="",  _
                                     Type:=2)
        .Shadow.Visible = False
        .Fill.Visible = True
        .Fill.ForeColor.RGB = vbGreen
        .Line.Visible = False
        .Line.ForeColor.RGB = vbRed
        .Line.Weight = LINEWGHT
        .Line.Transparency = 0
        End With
      
      MsgBox "Shape 1 Name: " & shp1.Name, , ""
      MsgBox "Shape 2 Name: " & shp2.Name, , ""
      MsgBox "Shape 3 Name: " & shp3.Name, , ""
    
    '  MsgBox "This information is on the first line. " & vbNewLine & _
    '         "This information is on the 2nd line. " & vbNewLine & _
    '         "This infornation is on the 3rd line. "
    '
    '  MsgBox "Shape 1 Name: " & shp1.Name, , "" & vbNewLine & _
    '         "Shape 2 Name: " & shp2.Name, , "" & vbNewLine & _
    '         "Shape 3 Name: " & shp3.Name, , ""
    
    '  On Error GoTo 0
    End Sub
    Thank you!
    Attached Files Attached Files
    Last edited by briskie; 04-19-2024 at 04:17 PM.

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