1
我有兩個選擇案例取決於.value條件,如果它是真或假。如果.value = true,那麼在沒有擴展的情況下使用大小寫,否則你的情況下WITH擴展一切似乎工作,但是我得到一個控制變量已經在使用。我如何使用多個控制變量?請看下面的代碼如何在一個表格中有兩個控制變量
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
'下一個cel'行重複兩次 – dbmitch