0

この特定のコードについてフォーラムで受けた支援に感謝します。そこから持ってきたと思っていたのですが、もう一度お願いします。私ができる最善の説明は、以下の疑似コードにあると思います! このケース選択部分が完了したら、参照セルを変更するだけで済むように、月を通して同じプロセスを繰り返します。

Sub PopCol()


Range("D3:D19").Formula = "=RC[-1]-RC[-2]"  'D=C-B , Delta is equal to Cap minus Dem
    For i = 3 To 19
    Range("D" & i) = CLng(Range("C" & i) - Range("B" & i))
    If (Range("D" & i) < 0) Then
        Range("E" & i) = Range("E" & i) - Range("D" & i)
    Else
        Range("F" & i) = Range("F" & i) + Range("D" & i)
    End If
Next

Range("G3:G19").Formula = "=RC[-1]-RC[-2]"  'G=F-E , Delta is equal to Cap minus Dem

'if delta (h)= capacity (G) continue, if g<0 go back over prior months to where is negative and add   
 to    capacity
'then recalculate, else g>0 - go back over prior months and subtract(a neg) from demand (same as 
adding absolute value). then recalculate all.

For i = 3 To 19
    Range("G" & i) = CLng(Range("F" & i) - Range("E" & i))
Select Case (Range("G" & i)) 'May
   'Case "G" = Range ("F" & i)  Continue
Case Is = Range("F" & i)
          GoTo Line 35

'Case "G" < "0" check D if >0,("D"&i)=("D"&i)-("G" & i) 
     '{then compare D with C, balance over equal is placed in G and D & C end up equal. goto beginning of sub}
Case Is < "0"
        ("D"&i)=("D"&i)-("G" & i)else Goto Line 5

Case Else
     'case "G" > "0" check D if <0,("C"&i)=("C"&i)-("G" & i) "(then compare D with C, balance over 
equal is placed in G and D & C end up equal.goto beginning of sub}
    If Range("G" & i) > "0" Then
End Select

'next is June
For i = 3 To 19
    Range("J" & i) = CLng(Range("I" & i) - Range("H" & i))
Select Case "June"
    'Case "H" = Range ("F" & i)  Continue
    'Case "H" < "0" check G if >0,("G"&i)=("G"&i)-("J" & i) {then compare G with F, balance over 
equal    is placed in J and G & F end up equal. goto beginning of sub}
    'case "H" > "0" check G if <0,("F"&i)=("F"&i)-("J" & i) (then compare G with F, balance over equal 
is placed in J and G & F end up equal. goto beginning of sub}
End Select

Next

'COntinue on with July, August, Sept, Oct, Nov, Dec, Jan 14, Feb 14 but in FEb 14 place balance over 
equal in

End Sub

ありがとうございます!

4

1 に答える 1

0

あなたの質問は非常にわかりにくいです。あなたのコードがどのように見えるべきかの例を投稿しました。うまくいけば、空白を埋めることができます.

For i = 3 To 19
    Range("G" & i).Value = CLng(Range("F" & i).Value) - CLng(Range("E" & i).Value)
    Select Case CLng((Range("G" & i)).Value)
        Case CLng(Range("F" & i).Value)
              GoTo Line 35
        Case < "0"
            '("D"&i)=("D"&i)-("G" & i)else Goto Line 5  <--- very wrong, use the 2nd to see reformat this line.
        Case Else
            GoTo Line 35
    End Select
Next i
于 2013-04-01T19:05:35.177 に答える