Multiple variables in MsgBox

smiffy197

New Member
Joined
Aug 21, 2015
Messages
4
Hi There,

I am trying to get a pop up message box to display a list of names that may change each time you open the sheet.

I deal with new starters at work and want to have a popup box that finds the users who are starting in the next 2 weeks and haven't already been assigned a laptop. I have the code sorted to the point where I have a list of these people on a separate sheet, but I want a MsgBox to display them like this:

The following users haven't been assigned laptops:

Firstname Lastname
Firstname Lastname
etc.

I can get the message box to display the first name on the list but don't know how to add the rest. Any help would be appreciated because I have spent a couple of days on this now and got no where!

Many Thanks
J
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Something like this perhaps:

Code:
-

MsgBox "The following users haven't been assigned laptops:" & vbNewLine & Firstname & " " & Lastname & vbNewline & Firstname & " " & Lastname & vbNewline ....


-
 
Upvote 0
Thanks dreid,

That's pretty much as far as I have got at the moment but the names are variables based on cell references and the number of names might change each time

Sometimes you'll open the sheet and have 6 people sometimes only one or two.

The way you suggested, which is a method I have tried leaves lots of blank space in the MsgBox if there is only one persons name.
 
Upvote 0
Managed to get this working.
This is the bit of the code I was stuck on.

Code:
 Dim c As Range
                Dim strng As String
        
                    Set c = Range("A2").End(xlDown)
                    k = 1
                    Do
                        k = k + 1
                        strng = strng & Cells(k, 4) & " " & Chr(13)
                    Loop Until k = c.Row
                    
                    '//Displays message for multiple users
                    MsgBox "The following users will start soon and have not been assigned laptops: " & vbNewLine & vbNewLine & strng, vbInformation, "Welcome"
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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