|
▼隼 さん
単純なミスだけ、直してみました。
Sub 引き算()
Dim lastgyou As Integer
Dim i As Integer
Dim j As Integer
Dim atai As Integer
Sheets("Sheet1").Select
ActiveSheet.Range("A1").End(xlDown).Select
lastgyou = ActiveCell.Row
For i = 1 To lastgyou - 1
atai = ActiveSheet.Cells(i, 1).Value
For j = i + 1 To lastgyou
If atai = ActiveSheet.Cells(j, 1).Value Then
Range("C" & i) = Range("B" & i) - Range("B" & j)
If Range("C" & i) < 0 Then
Range("A" & i).Interior.ColorIndex = 3
Range("A" & j, "B" & j).Delete
End If
End If
Next
Next
End Sub
|
|