目前我有12条这样的行,带有12个选项按钮:
If OptionButton1.Value = True Then
Cells(emptyRow, colnum).Value = 1
End If
我想替换为
For i = 1 To 3 '1 question
If OptionButton1.Value = True Then
Cells(emptyRow, colnum).Value = 1
End If
Next i
我该如何正确编写:“ OptionButton”&i.Value,以使i为数字,而OptionButton始终相同?
尝试了注释中的解决方案,将我的代码变成了这个,我遇到了编译错误。 labelstrr突出显示为错误。
Dim i As Integer
Dim j As Integer
Dim labelstrr As String
Dim labelnum As Integer
For j = 1 To 4 'columns 1 to 4
For i = 1 To 3 '1 optionbutton
labelstrr = "OptionButton" & labelnum
If labelstrr.Value = True Then
Cells(emptyRow, j).Value = i
labelnum = labelnum + 1
End If
Next i
Next j