print msgbox on new sheet

Godwin117

Board Regular
Joined
Dec 19, 2019
Messages
68
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I'm looking for VBA that if the person selects yes, the information that was in the message box will be pasted into another sheet that is created. A1 will say "Type" B1 will say "name", A2 and down will have the information from sheet1.Range("b" & VNR). B2 and down will have the information from sheet1.Range("c" & VNR). That's the part I can't figure out, I also might be thinking about it the wrong way too. It's just an OK message now, but it'll be changed to Yes and No. Thank you in advance for your assistance.

VBA Code:
Sub Show_MSGBOX()

Dim vN As Long
Dim VNR As Long
Dim vMsg As String
vN = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row

If Sheets("Sheet2").Range("AU10").Value = 0 Then

    For VNR = 3 To Sheets("Sheet2").Range("AV10").Value
        If Sheets("Leg").Range("H" & VNR).Value = "Leg" Then
            vMsg = vMsg & Sheets("Sheet1").Range("B" & VNR) & vbTab & Sheets("Sheet1").Range("C" & VNR) & vbCrLf
        End If
        
    Next VNR
    MsgBox ("Missing Count: " & Sheets("Sheet2").Range("AU10").Value & vbCrLf & vbCrLf & "Type" & vbTab & "     Name" & vbCrLf & vMsg)
Else
    For VNR = 3 To Sheets("Dashboard").Range("AV10").Value
        If Sheets("Leg").Range("H" & VNR).Value = "Leg" Then
            vMsg = vMsg & Sheets("Sheet1").Range("B" & VNR) & vbTab & Sheets("Sheet1").Range("C" & VNR) & vbCrLf
        End If
        
    Next VNR
    MsgBox ("Missing Count: " & Sheets("Sheet2").Range("AU10").Value & vbCrLf & vbCrLf & "Type" & vbTab & "     Name" & vbCrLf & vMsg & vbCrLf & vbCrLf & "** Please Select By name to view all personnel. **")
End If

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,215,420
Messages
6,124,803
Members
449,190
Latest member
cindykay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top