Create new line on Messagebox

     

  • Create new line on Message box
  • Private Sub CommandButton1_Click()
    Dim i As Integer
    For i = 1 To 15
    Nline = Nline & Range("A" & i).Value & vbNewLine
    Next
    MsgBox Nline
    End Sub

     

     

    Message box Buttons

     

    Private Sub CommandButton1_Click()
    Dim output As String
    output = MsgBox("mention the result", vbYesNoCancel + vbDefaultButton2 + vbQuestion)
    If output = vbYes Then
    Range("A1").Value = "sriguranjani"
    Else
    Range("A1").Value = "hello"
    End If
    End Sub

     

     

     

    Open required workbook based on Message box response

     

    Private Sub CommandButton1_Click()
    Dim source As String, Filename As String, reponse As String
    source = "D:\Consolidation\"
    Filename = Dir(source & "*.x??")
    Dim r As Integer
    Do While Filename <> ""
    i = i + 1
    Sheets("Sheet2").Cells(i, 1) = Filename
    response = MsgBox(Filename, vbYesNoCancel)
    If response = vbYes Then
    Workbooks.Open (source & Filename)
    End If
    Filename = Dir
    Loop
    End Sub

     

     

    Open required workbook based on Message box response - Dynamic

     

     

    Private Sub CommandButton1_Click()
    Dim Source As String, Filename As String, reponse As String
    Source = Range("D3").Value & ":\" & Range("G3").Value & "\"
    'Source = "D:\Consolidation\"
    Filename = Dir(Source & "*.x??")
    Dim r As Integer
    Do While Filename <> ""
    ThisWorkbook.Activate
    i = i + 1
    Sheets("Sheet2").Cells(i, 1) = Filename
    response = MsgBox(Filename, vbYesNoCancel)
    If response = vbYes Then
    Workbooks.Open (Source & Filename)
    End If
    Filename = Dir
    Loop
    End Sub

     

     

     

     

    Delete Active Cells - Message Box respose

     

     

    Private Sub CommandButton1_Click()
    Do Until ans = vbCancel
    ans = MsgBox("delete the activecell", vbYesNoCancel)
    If ans = vbYes Then
    ActiveCell.EntireRow.Delete
    Else
    ActiveCell.Offset(1, 0).Select
    End If
    Loop
    End Sub