Hi Folks,
Excel Max has helped me understand a useful way to link option button choices in a userform to a Case SELECT inside my vba code. This code takes the choice of option box and returns it when the ActiveOption function is called from the userform code.
I then use the choice in CASE to execute some code like the snip below.
This works fine with option buttons, but I am struggling to figure out
Excel Max has helped me understand a useful way to link option button choices in a userform to a Case SELECT inside my vba code. This code takes the choice of option box and returns it when the ActiveOption function is called from the userform code.
VBA Code:
Function ActiveOption()
vA = Array("optCenter", "optAbove", "optRight", "optBelow", "optLeft")
For vN = 0 To UBound(vA)
If Controls(vA(vN)) Then ActiveOption = vA(vN): Exit Function
Next vN
End Function
I then use the choice in CASE to execute some code like the snip below.
VBA Code:
'>>>>>>>>>>>>>>>>>>>> ActiveOption Function Call <<<<<<<<<<<<<<<<<<<<<
Select Case ActiveOption
Case "optAbove"
.VerticalAlignment = xlVAlignBottom
This works fine with option buttons, but I am struggling to figure out
- how to use the same "Function" approach on a Combobox or other object/multiple objects.
- how to have multiple uses of this in one userform. I get an error object not found shown in the image below when I try to do something similar on a combobox.
- I am trying to use this approach on three selection areas in my userform (two separate option boxes inside frames and one combobox), but past using only one, I get an error "could not find specified object"