Dropdown sometimes other times auto value

Mrstinkleton

New Member
Joined
Sep 1, 2017
Messages
5
Hi all I'm hoping someone can help. Look all over for a solution but no look. Now I'm pretty proficient with Excel and not bad at VBA (still refreshing my skills) bit I'm stuck! Let me try to explain. I want a cell to autopopulate with M or F for gender if the group looks like this 10CS-B or 10CS-G but if the group looks like this 10CS-M I want dropdown to become enabled so I can select M or F depending on the gender of the student as 10CS-M for example would be a mixed gender group. Thanks all.
 
This is another option, that will ask the user to input a value for the mixed classes
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("B:B")) Is Nothing Then
        If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
        Select Case Right(Target.Value, 1)
            Case "B"
                Target.Offset(, 2) = "M"
            Case "G"
                Target.Offset(, 2) = "F"
            Case "M"
                Target.Offset(, 2) = InputBox("Please enter M or F for " & vbLf & "group " & Target.Value)
        End Select
    End If
    
End Sub
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I thought of this myself but thougth it would be easier to just do it manually. But we will see.
This is another option, that will ask the user to input a value for the mixed classes
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("B:B")) Is Nothing Then
        If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
        Select Case Right(Target.Value, 1)
            Case "B"
                Target.Offset(, 2) = "M"
            Case "G"
                Target.Offset(, 2) = "F"
            Case "M"
                Target.Offset(, 2) = InputBox("Please enter M or F for " & vbLf & "group " & Target.Value)
        End Select
    End If
    
End Sub
 
Upvote 0
I thought of this myself but thougth it would be easier to just do it manually. But we will see.

Tend to agree, but as the OP initially asked for a dropdown to be enabled, I thought I'd give a similar solution.
 
Upvote 0
Here is another option:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B:B")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Value = "10CS-B" Then Target.Offset(, 2).Value = "M"
If Target.Value = "10CS-G" Then Target.Offset(, 2).Value = "F"
If Target.Value = "10CS-M" Then
ans = MsgBox("Choose Yes for M" & vbNewLine & "Choose No for F", vbYesNo + vbQuestion, "My Answer")
If ans = vbYes Then Target.Offset(, 2).Value = "M"
If ans = vbNo Then Target.Offset.Offset(, 2).Value = "F"
End If
End If
End Sub
 
Upvote 0
Thank you all. I Wil try these solutions. In the meantime as time was against me, I used conditional formatting to colour the cells if single gender and disabled menu. This works quite well and avoids VBA, as on the analysis Shef I can use an if function to say M or F if needed or the gender as input for a mixed class.
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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