Message box for multiple values

martinsimart

New Member
Joined
Mar 23, 2018
Messages
9
Hi

I want to adapt the below code so that if I entered a name from a choice of say 10 names it would bring up a message box
with their managers name. The code below works for one name but how do i add to it?


Sub manager()
If Range("A1").Value = "Martin" Then
MsgBox "Lee", Title:="Manager is"

End If
End Sub


Thanks

Mart
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
If it really is just 10 names, it would probably be easier to copy what you have rather than set up a Vlookup table.

Or maybe better yet:

Code:
Select case Range("A1").Value
    Case "Bob"
        msgbox "Bob's Manager",,"Manager Is:"
    Case "Joe"
        msgbox "Joe's Manager",,"Manager Is:"
    Case "Tom"
        msgbox "Tom's Manager",,"Manager Is:"
    Case "Tim"
        msgbox "Tim's Manager",,"Manager Is:"
End Select

or somethin like that.
 
Last edited:
Upvote 0
You would need to have a list of names, let's say in column A and their corresponding manager's name in column B. Do you have that data?
 
Upvote 0
Hi

The answer from jproffer works a treat

I only have appox eight team members for 7 managers so it's not a problem entering them (I suppose there would be another way if you had lots of manes)

Many thanks
 
Upvote 0
Yes, if you had 10000 names, I wouldn't have even suggested a Case Select. If you did, then mumps way would be better. Make a table, then have VBA do a VLookup to find the manager.

And BTW, that way would work, but I try to keep my "things I need to hide from the end user" to a minumum...such as V Lookup tables in hidden worksheets, etc.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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