2016-07-29 2 views
1

true 또는 false 인 경우 .value 조건에 따라 두 가지 선택 사례가 있습니다. .value = true이면 확장을 사용하지 말고 use를 사용하면 모든 것이 확장 된 것처럼 보이지만, 이미 사용중인 제어 변수를 얻고 있습니다. 여러 제어 변수를 사용하려면 어떻게해야합니까? 그냥 당신이 각 셀에 뭘하려고하는지 모르겠 대상 변수 이름을 물론양식에 두 개의 제어 변수를 사용하는 방법

을 변경 - - 당신이 두 개의 for 루프를 사용하려는 경우

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 
+0

'다음 셀'줄이 두 번 반복됩니다. – dbmitch

답변

2

아래 코드를 참조하십시오 그래서 확인 어떻게하면 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 
관련 문제