Realjoshtodd
New Member
- Joined
- Sep 26, 2017
- Messages
- 34
Ok I have the following code listed below to clear the Optionbuttons and any text from parts of Sheet 2. I need to also reset and clear the ComboBox (there is 8) to be blank. There is also two text boxs that I need to clear as well. When I add
ElseIf TypeName(box.Object) = "Combobox" Then
box.Object.Clear
it gives me an error.
Sub ClearAll()
Dim box As OLEObject
Worksheets("Sheet2").Rows("1:1").ClearContents
Worksheets("Sheet2").Range("M4").ClearContents
Worksheets("Sheet2").Range("F12", "J12").ClearContents
For Each box In ActiveSheet.OLEObjects
If TypeName(box.Object) = "OptionButton" Then
box.Object.Value = False
ElseIf TypeName(box.Object) = "CheckBox" Then
box.Object.Value = False
ElseIf TypeName(box.Object) = "ListBox" Then
box.Object.Clear
End If
Next box
End Sub
ElseIf TypeName(box.Object) = "Combobox" Then
box.Object.Clear
it gives me an error.
Sub ClearAll()
Dim box As OLEObject
Worksheets("Sheet2").Rows("1:1").ClearContents
Worksheets("Sheet2").Range("M4").ClearContents
Worksheets("Sheet2").Range("F12", "J12").ClearContents
For Each box In ActiveSheet.OLEObjects
If TypeName(box.Object) = "OptionButton" Then
box.Object.Value = False
ElseIf TypeName(box.Object) = "CheckBox" Then
box.Object.Value = False
ElseIf TypeName(box.Object) = "ListBox" Then
box.Object.Clear
End If
Next box
End Sub