返回列表 上一主題 發帖

有關OptionButton迴圈問題

若不用OptionButton_Click事件改用一個過程執行倒可以建立個迴圈一一判斷。
要用OptionButton_Click事件執行的話,得用到物件類別模組。

TOP

Sub yy()
    Dim o As OLEObject, c%
    For Each o In Me.OLEObjects
        If o.Name Like "OptionButton" & "*" Then
            If o.Object.Value = True Then
                c = Replace(o.Name, "OptionButton", "")
                Cells(1, 2).Value = Cells(c, 2): Exit For
            End If
        End If
    Next
End Sub
這樣就是迴圈,但你必須執行這個程式而不是點擊OptionButton後自動執行!

TOP

        靜思自在 : 人要自愛,才能愛普天下的人。
返回列表 上一主題