JasonEnsor
Programmer
Hi Guy's
I might be being daft but for some reason I can't get this code to work. I am using a VBA Userform in Excel 2010.
My first for loop works for setting the value of the textboxes in the frame. The issue I am facing is I can not get it to update the value of the checkboxes. I get an error 13 type miss match on the
.
As I have loads of textboxes, comboboxes and checkboxes on my userform I thought looping would be a good way to clear the userform as my userform is set up using frames to separate the different sections.
I am currently testing this on a userform with a single frame, two textboxes and two checkboxes.
Any help would be appreciated.
J.
I might be being daft but for some reason I can't get this code to work. I am using a VBA Userform in Excel 2010.
Code:
Option Explicit
Dim t As MSForms.TextBox
Dim chk As MSForms.CheckBox
Private Sub CommandButton1_Click()
For Each t In UserForm1.Frame1.Controls
On Error Resume Next
t.Value = CCur(t.Value)
If Err.Number <> 0 Then
t.Value = Format$(0, "Currency")
MsgBox "Error"
On Error GoTo 0
End If
t.Value = Format$(t.Value, "Currency")
Next t
For Each chk In UserForm1.Frame1.Controls
chk.Value = True
Next chk
End Sub
My first for loop works for setting the value of the textboxes in the frame. The issue I am facing is I can not get it to update the value of the checkboxes. I get an error 13 type miss match on the
Code:
next t
As I have loads of textboxes, comboboxes and checkboxes on my userform I thought looping would be a good way to clear the userform as my userform is set up using frames to separate the different sections.
I am currently testing this on a userform with a single frame, two textboxes and two checkboxes.
Any help would be appreciated.
J.