list

cmccabe

Active Member
Joined
Feb 20, 2008
Messages
396
I am using the code below, which works great. Is it possible to use a validation list as a user prompt? So instead of entering data , the user is prompted with a list. The list would be Offset, 5 and is called Age (cells G198:G200). Thanks.

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim x As Variant
If Intersect(Target, Range("A3:A53")) Is Nothing Then Exit Sub
Cancel = True
x = Application.InputBox("Enter Case Number Between 1 and 50", "You must Enter a Value or click Cancel to exit this procedure", Type:=1)
If x = False Then Exit Sub
Target.Value = x
Do While Target.Value < 1 Or Target.Value > 50
    Target.Value = InputBox("Enter a number Between 1 and 50", "Input Out of Range!")
Loop
Target.Offset(, 4).Value = InputBox("Enter Age", "You must Enter a Value")
Do While Target.Offset(, 4).Value < 1 Or Target.Offset(, 4).Value > 150
    Target.Offset(, 4).Value = InputBox("Enter a number Between 1 and 150", "Input Out of Range!")
Loop
Target.Offset(, 13).Value = InputBox("Enter Donor", "You must Enter Text")
Do While IsNumeric(Target.Offset(, 13).Value) Or Target.Offset(, 13).Value = ""
    Target.Offset(, 13).Value = InputBox("Enter Donor", "Error!")
Loop
Target.Offset(, 14).Value = InputBox("Enter Description", "You must Enter Text")
Do While IsNumeric(Target.Offset(, 14).Value) Or Target.Offset(, 14).Value = ""
    Target.Offset(, 14).Value = InputBox("Enter Description", "Error!")
Loop
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You would have to design a small userform to popup with a ListBox on it. A listbox can display the listed items from any range of cells you indicate, and the value selected can be sent into another macro.
 
Upvote 0
Can I add a staement to the code that requires the answer to be Yes or No and if yes checks a box and if no does not? Thanks.

Code:
Target.Offset(, 8).Value = InputBox("Was LSAB Used", "You must Enter Text")
Do While IsNumeric(Target.Offset(, 8).Value) Or Target.Offset(, 8).Value = ""
    Target.Offset(, 8).Value = InputBox("Was LSAB Used", "Error!")
Loop
 
Upvote 0
Don't give them a choice, use a better InputBox:
Code:
Target.Offset(, 8).Value = _
    MsgBox("Was LSAB Used?", vbYesNo + vbQuestion, "LSAB Check")
 
Upvote 0

Forum statistics

Threads
1,224,596
Messages
6,179,807
Members
452,944
Latest member
2558216095

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