简体   繁体   中英

excel vba Multiple check boxes

I'm trying to collect the status of many Check Boxes in a User form and write X for check box that is in a False status Or V when it is in True status, but I always get the run time error when It gets to the line:

For Each chk In UserForm1

Run-Time error '438': Object Doesn't support this property or method

Here is what I have so far:

    Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim Col As Long
Dim chk As Control
Set ws = Worksheets("Sheet1")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 1).Row
Col = 1
MultiPage1.Value = 1
For Each chk In UserForm1
    If GroupName = Rooms Then
        If (chk.Value) = True Then
            ws.Cells(iRow, Col).Value = V
            Col = Col + 1
        End If
        Else
            ws.Cells(iRow, Col).Value = X
            Col = Col + 1
    End If
Next
End Sub

Any Suggestions?

Thanks in advance for any help or leads

在用户窗体的控件上指定循环。

For Each chk In UserForm1.Controls

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM