问题是:
If UserForm1.Controls(I).Value = "True" Then
不带引号
If UserForm1.Controls(I).Value = True Then
FltrTpye
必须是
String
不
Double
但是有很多小错误,代码重写:
Dim Num As Integer
Dim I As Integer
Dim FltrTypes() As String
Dim NFltrTypes As Long
Num = UserForm1.Controls.Count - 1
Erase FltrTypes
NFltrTypes = 0
For I = 0 To (Num - 1)
If Left(UserForm1.Controls(I).Name, 8) = "CheckBox" Then
If UserForm1.Controls(I).Value = True Then
ReDim Preserve FltrTypes(NFltrTypes)
NFltrTypes = NFltrTypes + 1
FltrTypes(NFltrTypes - 1) = UserForm1.Controls(I).Caption
End If
End If
Next I