Bruiser616
New Member
- Joined
- Feb 19, 2005
- Messages
- 8
I have a spreadsheet that I would like to pop up an input box to prompt the user to give one of 4 values. I only want this to work for Column C and I would like the Input Box to pop up when a cell is clicked in (preferably the right-click button). Depending on the value the background shading will be changed.
Here is what I have so far. Part of the error handling is commented out for testing.
Sub ColorSupportType()
With Range("C2:D1")
BoxColor = InputBox("Enter S for Successful, P for Partial, F for Failed, or SH for Shadow. Click cancel if no change is needed.", "Support Success?")
'Error Handling
If BoxColor = " " Then 'Or Not "S" Or Not "P" Or Not "F" Or Not "SH" Then
MsgBox "Please enter S, P, F, or SH", "Invalid Entry"
End If
If BoxColor = "S" Then
ActiveCell.Interior.ColorIndex = 4
ElseIf BoxColor = "P" Then
ActiveCell.Interior.ColorIndex = 6
ElseIf BoxColor = "F" Then
ActiveCell.Interior.ColorIndex = 3
ElseIf BoxColor = "SH" Then
ActiveCell.Interior.ColorIndex = 15
End If
End With
End Sub
1. I specified the Range but it lets you use this from any Cell. I only want to use it for Column C cells.
2. I can't figure out to get the error checking to work. Is "Or Not" an invalid condition in VBA?
3. How do I get the right click popup to work?
Thanks!
Here is what I have so far. Part of the error handling is commented out for testing.
Sub ColorSupportType()
With Range("C2:D1")
BoxColor = InputBox("Enter S for Successful, P for Partial, F for Failed, or SH for Shadow. Click cancel if no change is needed.", "Support Success?")
'Error Handling
If BoxColor = " " Then 'Or Not "S" Or Not "P" Or Not "F" Or Not "SH" Then
MsgBox "Please enter S, P, F, or SH", "Invalid Entry"
End If
If BoxColor = "S" Then
ActiveCell.Interior.ColorIndex = 4
ElseIf BoxColor = "P" Then
ActiveCell.Interior.ColorIndex = 6
ElseIf BoxColor = "F" Then
ActiveCell.Interior.ColorIndex = 3
ElseIf BoxColor = "SH" Then
ActiveCell.Interior.ColorIndex = 15
End If
End With
End Sub
1. I specified the Range but it lets you use this from any Cell. I only want to use it for Column C cells.
2. I can't figure out to get the error checking to work. Is "Or Not" an invalid condition in VBA?
3. How do I get the right click popup to work?
Thanks!