MsgBox display layout

julhs

Active Member
Joined
Dec 3, 2018
Messages
454
Office Version
  1. 2010
Platform
  1. Windows
Using helper cells (“B117:B120”), the code I have below does display the MsgBox in the format that I want.
However, is there any way to do this without hard coding the individual cells but use a Named Range for the helper cells instead?
If there is, nothing I’ve tried works
My code is this,
VBA Code:
Sub MsgBoxMissingNames()
MsgBox "Missing names are:-" _
& vbCrLf & " " & Range("B117").Value _
& vbCrLf & " " & Range("B118").Value _
& vbCrLf & " " & Range("B119").Value _
& vbCrLf & " " & Range("B120").Value, vbOKOnly
Range("MissingNames").Select ‘This is the helper cells Named Range
End Sub
Nearest thing I came up with as a way of compromise was:
VBA Code:
>>
Dim r As Range, ary
Set r = Sheets("Sheet1").Range("MissingNames")
With Application
MsgBox " Missing names are:-" & vbCrLf & _
Join(.Transpose(r), " & ")
>>
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
VBA Code:
MsgBox " Missing names are:-" & vbCrLf & " " & _
Join(.Transpose(r), vbLf & " ")
 
Last edited:
Upvote 0
Try:

VBA Code:
Sub MsgBoxMissingNames()
  MsgBox "Missing names are:-" & vbCr & Join(Application.Transpose(Range("MissingNames").Value), vbCr)
End Sub
 
Upvote 0
Thank you both for response.
As both work for me, all be it with different syntax and I can only mark one as a solution, all I can do is mark both as “Like”

Thank you both again.

Julhs
 
Upvote 0

Forum statistics

Threads
1,221,531
Messages
6,160,366
Members
451,642
Latest member
mirofa

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