3

I have a combo box named "Facility" that has been added as a form control to an Excel 2010 worksheet. I also have a module titled "AdjustmentsAmount" that is running the below method on a form button click. I've tried several methods of accessing the form control, and none work, also listed below. Can anyone shed light on this subject please?

Code

'Clears all run specifications
Sub clearRunSpecs_click()
    Dim resp As String
    resp = MsgBox("This will clear all run specifications. Are you sure you want to continue?", vbYesNo)
    If (resp = vbYes) Then
        Worksheets("AdjustmentsAmount").Unprotect "pass"
        Range("D3").Clear
        Range("D3").Interior.Color = RGB(235, 241, 222)
        Range("D3").BorderAround LineStyle:=XlLineStyle.xlContinuous, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic, Color:=RGB(0, 0, 0)
        Range("D3").Locked = False
        Range("D4").Clear
        Range("D4").Interior.Color = RGB(235, 241, 222)
        Range("D4").BorderAround LineStyle:=XlLineStyle.xlContinuous, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic, Color:=RGB(0, 0, 0)
        Range("D4").Locked = False
        Range("B4").Clear
        Range("B4").Interior.Color = RGB(235, 241, 222)
        Range("B4").BorderAround LineStyle:=XlLineStyle.xlContinuous, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic, Color:=RGB(0, 0, 0)
        Range("B4").Locked = False
        Range("A17:D22").Clear
        Range("A17:D22").Merge
        Range("A17:D22").Interior.Color = RGB(235, 241, 222)
        Range("A17:D22").BorderAround LineStyle:=XlLineStyle.xlContinuous, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic, Color:=RGB(0, 0, 0)
        Range("A17:D22").VerticalAlignment = xlTop
        Range("A17:D22").Locked = False
        ActiveSheet.Shapes("Facility").ListIndex = -1
        ActiveSheet.CheckBoxes("ZeroBalance").Value = xlOff
        ActiveSheet.CheckBoxes("Balance<Adj").Value = xlOff
        ActiveSheet.CheckBoxes("Balance=Adj").Value = xlOff
        Worksheets("AdjustmentsAmount").Protect "pass"
    End If
End Sub

Methods tried

ActiveSheet.Shapes("Facility")
ActiveSheet.Facility
ActiveSheet.ListBoxes("Facility")
Application.Facility

I have accessed checkboxes in the same method using ActiveSheet.CheckBoxes("NAME") and that worked fine. However, I can't seem to get ahold of the combo box.

4

2 に答える 2

1

少し隠されています-次のようにリストボックスまたはコンボボックスにアクセスできます:

Debug.Print ActiveSheet.Shapes("Facility").OLEFormat.Object.Value
于 2013-03-19T12:45:46.613 に答える
1

空白行を ListIndex1 に設定して使用しました。

ActiveSheet.Shapes("Facility").ControlFormat.ListIndex = 1

をクリックしてアクセスします。私はそれがあなたが必要とするものだと思いますか?

于 2013-03-19T12:54:36.757 に答える