Combo Boxes
I've got that working however I have to enter the name of the combobox
that I am working on (your_combo_box_name) - this is the value I am
trying to get see my code below:
So for instance I need to get currentcomboboxname so that I can use it
to specify the other shapes - currently "ot12" and "mt12" - can i do
that with his code? - am I missing something here ?
strVariable = ReturnCBOName(currentcomboboxname)
If Range("D12").Value = "Other" Then
ActiveSheet.Shapes("ot12").Visible = True
ActiveSheet.Shapes("mt12").Visible = True
Else:
If ActiveSheet.OLEObjects("ot12").Object.Text = "" Then
ActiveSheet.OLEObjects("ot12").Visible = False
ActiveSheet.OLEObjects("mt12").Visible = False
Else
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "You have already entered text in a field. Press Yes
to continue and delete all text, press No to return." ' Define
message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define
buttons.
Title = "Error" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
ActiveSheet.OLEObjects("ot12").Object.Text = ""
ActiveSheet.OLEObjects("mt12").Visible = False
ActiveSheet.OLEObjects("ot12").Visible = False
Else ' User chose No.
Range("D12").Value = "7"
End If
End If
End If
End Sub
Function ReturnCBOName(Optional ByVal cboBox As MSForms.ComboBox) As
String
ReturnCBOName = cboBox.Name
End Function
|