Bagharmin
Board Regular
- Joined
- Nov 22, 2010
- Messages
- 168
I already have a nice little loop that I use to clear all the controls on a userform I created. The main part of the code is below.
What I'm wanting to do now is come up with a way to store all the values of all the controls in another nice little loop. What I came up with was:
VBA doesn't like it. "X" is dim'd as Integer, Choice() as Variant, and COptions as Control and I ReDim'd Choice at the beginning of the code. I want the loop to go through each control on the userform and store it's value, whether it's a T/F value, number, or text. However, I keep getting an "Object doesn't support this property or method" error at the "Choice(X) = COptions.Value" line. Is there a way to do what I'm trying to do?
Code:
For Each COptions In UserForm1.Controls
If TypeName(COptions) = "CheckBox" Or TypeName(COptions) = "OptionButton" Or TypeName(COptions) = "TextBox" Then
COptions.Value = False
End If
Next
What I'm wanting to do now is come up with a way to store all the values of all the controls in another nice little loop. What I came up with was:
Code:
For Each COptions In UserForm1.Controls
X = X + 1
Choice(X) = COptions.Value
Next
VBA doesn't like it. "X" is dim'd as Integer, Choice() as Variant, and COptions as Control and I ReDim'd Choice at the beginning of the code. I want the loop to go through each control on the userform and store it's value, whether it's a T/F value, number, or text. However, I keep getting an "Object doesn't support this property or method" error at the "Choice(X) = COptions.Value" line. Is there a way to do what I'm trying to do?
Last edited: