excel vba对于每个语句

时间:2018-10-09 05:54:47

标签: excel-vba

我需要有关填充每个语句的For

  • 基于数量的xlFillValues数字
  • Num_start xlFillSeries基于数量
  • 基于数量/ 120的Start_Pallet_Num xlFillValues

      Num              Quantity         Num_Start           Start_Pallet_Num
    720XA00000         10000            81000003                1261

2 个答案:

答案 0 :(得分:0)

Sub a()
quantity = Cells(2, 2).Value
For loop_ctr = 2 To quantity
Cells(loop_ctr + 1, 1) = Cells(2, 1).Value
Cells(loop_ctr + 1, 3) = Cells(loop_ctr, 3).Value + 1
Cells(loop_ctr + 1, 4) = quantity / 120
counter = counter + 1
Next loop_ctr
End Sub

尝试一下,让我知道您是否期望这样 I Got Output like this

否决

  Sub a()
    quantity = Cells(2, 2).Value
    stcount = 0
    stvalue = Cells(2, 4).Value
    For loop_ctr = 2 To quantity
    Cells(loop_ctr + 1, 1) = Cells(2, 1).Value
    Cells(loop_ctr + 1, 3) = Cells(loop_ctr, 3).Value + 1
    If quantity / 120 > 83 Then
       stcount = stcount + 1
          If stcount = 120 Then
          stvalue = stvalue + 1
          End If
        Cells(loop_ctr + 1, 4) = stvalue
    End If
    counter = counter + 1
    Next loop_ctr
    End Sub

答案 1 :(得分:0)

  Sub a()
    quantity = Cells(2, 2).Value
    stcount = 0
    stvalue = Cells(2, 4).Value
    For loop_ctr = 2 To quantity
    Cells(loop_ctr + 1, 1) = Cells(2, 1).Value
    Cells(loop_ctr + 1, 3) = Cells(loop_ctr, 3).Value + 1
    If quantity / 120 > 83 Then
       stcount = stcount + 1
          If stcount = 120 Then
          stvalue = stvalue + 1
          End If
        Cells(loop_ctr + 1, 4) = stvalue
    End If
    counter = counter + 1
    Next loop_ctr
    End Sub

尝试此代码