rcicconetti
New Member
- Joined
- Jan 16, 2016
- Messages
- 34
I am trying to display a msgbox if a user selects certain options in a dropdown box.
Here's the scenario.
This is for a scheduling assistant I am building.
Daily schedules have several cells with a dropdown lists that refer to the entire staff.
I know the staff's availability, so I have seperate lists containing that information.
The list of available employees for Monday AM can be found in ("Sheet2").Range("E11:E200")
*******
(Not sure if this is an issue, but this list (in Column E - Monday AM) is populated by a formula.)
=IF(OR(ISNUMBER(SEARCH({"Monday AM ONLY","Monday ANYTIME"},$C11))),$B11,"")
Where
Column B contains the Entire Staff.
Column C contains the availablity information.
Column E has only the names of employees available on Monday Morning (so there are several empty cells in this range)
*******
Assume a user is working on Monday's Schedule (found in Sheet20.) From a dropdown list, I choose "Johnny D."
Johnny D. isn't typically available on Mondays and although his name appears in the dropdown, it DOES NOT appear in ("Sheet2").Range("E11:E200")
I would like a msgbox to appear alerting the user that there is a conflict. I still want the ability to add Johnny to the list (on this particular Monday, he happens to be available) so using the B85:B200 as the validation list won't work. I just want to throw out a reminder to the scheduler that "This Employee is not typically available on this day." The user can hit "ok" ands continue on.
I've tried several combinations of ideas, but I can't seem to get the result that I'm looking for.
I've had an issue referencing ("Sheet2").Range("E11:E200") in the code, so I made a local reference on the sheet in Range(B85:B274). It's not ideal, but at least it got me closer to a result.
This was my most recent attempt. It gives me the EXACT OPPOSITE of what I want. If the name in the dropdown exists in Range(B85:B274), I get the msgbox, if it does not exist, I get nothing.
I assumed that changing "=" to "<>" would give me the correct result, but when I change line 3 to "If Cell.Value <> Target.Value Then" it throws the msgbox EVERYTIME, no matter what is selected.
Private Sub Worksheet_Change(ByVal Target As Range)
With Target.Value
For Each Cell In Range("B85:B274")
If Cell.Value = Target.Value Then
MsgBox "There is an AVAILABILITY CONFLICT with this Employee"
Exit For
Else
End If
Next
End With
End Sub
ANY HELP WOULD BE GREATLY APPRECIATED!!!!
THANKS
Here's the scenario.
This is for a scheduling assistant I am building.
Daily schedules have several cells with a dropdown lists that refer to the entire staff.
I know the staff's availability, so I have seperate lists containing that information.
The list of available employees for Monday AM can be found in ("Sheet2").Range("E11:E200")
*******
(Not sure if this is an issue, but this list (in Column E - Monday AM) is populated by a formula.)
=IF(OR(ISNUMBER(SEARCH({"Monday AM ONLY","Monday ANYTIME"},$C11))),$B11,"")
Where
Column B contains the Entire Staff.
Column C contains the availablity information.
Column E has only the names of employees available on Monday Morning (so there are several empty cells in this range)
*******
Assume a user is working on Monday's Schedule (found in Sheet20.) From a dropdown list, I choose "Johnny D."
Johnny D. isn't typically available on Mondays and although his name appears in the dropdown, it DOES NOT appear in ("Sheet2").Range("E11:E200")
I would like a msgbox to appear alerting the user that there is a conflict. I still want the ability to add Johnny to the list (on this particular Monday, he happens to be available) so using the B85:B200 as the validation list won't work. I just want to throw out a reminder to the scheduler that "This Employee is not typically available on this day." The user can hit "ok" ands continue on.
I've tried several combinations of ideas, but I can't seem to get the result that I'm looking for.
I've had an issue referencing ("Sheet2").Range("E11:E200") in the code, so I made a local reference on the sheet in Range(B85:B274). It's not ideal, but at least it got me closer to a result.
This was my most recent attempt. It gives me the EXACT OPPOSITE of what I want. If the name in the dropdown exists in Range(B85:B274), I get the msgbox, if it does not exist, I get nothing.
I assumed that changing "=" to "<>" would give me the correct result, but when I change line 3 to "If Cell.Value <> Target.Value Then" it throws the msgbox EVERYTIME, no matter what is selected.
Private Sub Worksheet_Change(ByVal Target As Range)
With Target.Value
For Each Cell In Range("B85:B274")
If Cell.Value = Target.Value Then
MsgBox "There is an AVAILABILITY CONFLICT with this Employee"
Exit For
Else
End If
Next
End With
End Sub
ANY HELP WOULD BE GREATLY APPRECIATED!!!!
THANKS