如何在一个表单中有两个控制variables

如果它是真或假,我有两个select案例取决于.value条件。 如果.value = true,那么使用大小写不扩展,否则你的情况下WITH扩展一切似乎工作,但是我得到一个控制variables已经在使用。 我如何使用多个控制variables? 请参阅下面的代码

If onetimeoption.value = True Then Select Case MonthComboBox.value Case "Week One" iCol = "AY" Case "Week Two" iCol = "AZ" Case "Week Three" iCol = "BA" Case "Week Four" iCol = "BB" Case "Week Five" iCol = "BC" Case "Week Six" iCol = "BD" Case "One Seven" iCol = "BE" Case "One Eight" iCol = "BF" Case "One Nine" iCol = "BG" Case "One Ten" iCol = "BH" Case "One Eleven" iCol = "BI" Case "One Twelve" iCol = "BJ" End Select Else nExtend = 1 'Set this as a default. Select Case MonthComboBox.value Case "Week One" iCol = "AY" nExtend = 12 Case "Week Two" iCol = "AZ" nExtend = 11 Case "Week Three" iCol = "BA" nExtend = 10 Case "Week Four" iCol = "BB" nExtend = 9 Case "Week Five" iCol = "BC" nExtend = 8 Case "Week Six" iCol = "BD" nExtend = 7 Case "One Seven" iCol = "BE" nExtend = 6 Case "One Eight" iCol = "BF" nExtend = 5 Case "One Nine" iCol = "BG" nExtend = 4 Case "One Ten" iCol = "BH" nExtend = 3 Case "One Eleven" iCol = "BI" nExtend = 2 Case "One Twelve" iCol = "BJ" nExtend = 1 End Select End If actWarehouse = Me.WarehouseComboBox.ListIndex + 1 With ws .Cells(irow, "A").value = Me.PartTextBox.value **For Each cel In .Cells(irow, iCol).Resize For Each cel In .Cells(irow, iCol).Resize(, nExtend)** cel.value = cel.value + CLng(Me.AddTextBox.value) cel.Interior.ColorIndex = 6 Next cel Next cel End With 

如果要使用两个for循环 – 只需更改目标variables名称即可

当然,我不知道你要对每个单元格做什么 – 所以请检查你要如何使用cel1和cel2 – 我只是猜测

  For Each cel1 In .Cells(irow, iCol).Resize For Each cel2 In .Cells(irow, iCol).Resize(, nExtend) cel1.value = cel2.value + CLng(Me.AddTextBox.value) cel1.Interior.ColorIndex = 6 Next cel2 Next cel1