This is where shg's suggestion would reduce setup time. It only involves inserting new columns and a bit of VBA placed in the Sheet Module to automate:
Code:
Option Explicit
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column > 9 And Target.Column < 26 Then
Select Case Target.Column
Case 10
If Target = "" Then
Target = "a"
Target.Font.Name = "Marlett"
Target.Offset(, 2) = ""
Target.Offset(, 4) = ""
Target.Offset(, 6) = ""
Target.Offset(, 8) = ""
Target.Offset(, 10) = ""
Target.Offset(, 12) = ""
Target.Offset(, 14) = ""
End If
Case 12, 14, 16, 18, 20, 22, 24
If Target = "" Then
Target = "a"
Target.Font.Name = "Marlett"
Target.Offset(, -1 * (Target.Column - 10)) = ""
Else
Target = ""
If Cells(Target.Row, 12) = "" And _
Cells(Target.Row, 14) = "" And _
Cells(Target.Row, 16) = "" And _
Cells(Target.Row, 18) = "" And _
Cells(Target.Row, 20) = "" And _
Cells(Target.Row, 22) = "" And _
Cells(Target.Row, 24) = "" Then
Target.Offset(, -1 * (Target.Column - 10)) = "a"
Target.Offset(, -1 * (Target.Column - 10)).Font.Name = "Marlett"
End If
End If
End Select
Cancel = True
End If
End Sub
I do understand what you'd like to accomplish however, as stated, a dropdown with checkboxes doesn't exist as far as I know.
If you place a listbox (with ckbx's) in the cell and leave the row height equal to one line of the list, you will still have to be clicking scroll controls to find your items to check/uncheck which seems just as laborious as multiple ckbx's across the sheet. And you'll need alot of VBA to control cell updates.
Another option is to increase row height to accommodate the entire list leaving all ckbx's exposed all the time, of course total over-all height of sheet increases significantly. And you'll need alot of VBA to control cell updates.
Another option is to increase listbox height when the listbox gets focus but a lot of VBA would be required to control cell updates and to make it dynamic.
The only other option I see is to go with a UserForm which I’ve done here:
Create UserForm1
Create TextBox1 in Userform1
Place this code in Userform1:
Code:
Option Explicit
Dim ProbArr As Variant
Dim x As Integer, r As Long
Dim skipevent As Boolean
Private Sub UserForm_Initialize()
r = ActiveCell.Row
ProbArr = Array("none", "arthritis", "asthma", "cardiac", "hypertension", "stomach", "HIV", "kidney")
Me.Height = 131.25
Me.Width = 106.5
Me.Caption = Cells(r, 1)
ListBox1.Height = 105.05
ListBox1.Width = 90
ListBox1.Top = 0
ListBox1.Left = 6
ListBox1.MultiSelect = fmMultiSelectMulti
ListBox1.ListStyle = fmListStyleOption
ListBox1.Clear
For x = 0 To UBound(ProbArr)
ListBox1.AddItem ProbArr(x)
Next x
For x = 11 To 18
skipevent = True
If Cells(r, x) <> "" Then
ListBox1.Selected(x - 11) = True
End If
skipevent = False
Next x
If NoneSelected Then
skipevent = True
ListBox1.Selected(0) = True
skipevent = False
End If
End Sub
Private Sub UserForm_Terminate()
For x = 11 To 18
If ListBox1.Selected(x - 11) Then
Cells(r, x) = ProbArr(x - 11)
Else
Cells(r, x) = ""
End If
Next x
End Sub
Private Sub ListBox1_Change()
If skipevent Then Exit Sub
Select Case ListBox1.ListIndex
Case 0
If ListBox1.Selected(0) Then
skipevent = True
For x = 1 To 7
ListBox1.Selected(x) = False
Next x
skipevent = False
Else
skipevent = True
ListBox1.Selected(0) = True
skipevent = False
End If
Case Else
If ListBox1.Selected(ListBox1.ListIndex) Then
skipevent = True
ListBox1.Selected(0) = False
skipevent = False
Else
If NoneSelected Then
skipevent = True
ListBox1.Selected(0) = True
skipevent = False
End If
End If
End Select
End Sub
Private Function NoneSelected()
NoneSelected = True
For x = 1 To 7
If ListBox1.Selected(x) = True Then
NoneSelected = False
Exit For
End If
Next x
End Function
Place this code in Sheet Module of your Patient Data Sheet:
Code:
Option Explicit
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 10 Then
If Cells(Target.Row, 1) <> "" Then
UserForm1.Show
Else
MsgBox "No Patient Data", vbCritical, "ERROR"
End If
Cancel = True
End If
End Sub
Right-clicking in Column J will bring up the form.