1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| Private Sub CommandButton1_Click()
'Rows(1).Delete
Dim DerCel As Long
DerCel = Worksheets("Sheet1").Range("B65536").End(xlUp).Row
Rows(DerCel + 1).Interior.Color = RGB(0, 0, 0)
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Application.ScreenUpdating = False
For i = 1 To DerCel
If Cells(i, 5).Value < 0 Then
For j = 1 To 9
Cells(i, j).Interior.Color = RGB(250, 0, 0)
Next j
Cells(i, 10).Value = 1
ElseIf Cells(i, 6).Value < 0 Then
For k = 1 To 9
Rows(i).Columns(k).Interior.Color = RGB(200, 100, 100)
Next k
Cells(i, 10).Value = 2
ElseIf Cells(i, 7).Value < 0 Then
For l = 1 To 9
Rows(i).Columns(l).Interior.Color = RGB(0, 250, 250)
Next l
Cells(i, 10).Value = 3
ElseIf Cells(i, 8).Value < 0 Then
For l = 1 To 9
Rows(i).Columns(l).Interior.Color = RGB(120, 120, 120)
Next l
Cells(i, 10).Value = 4
ElseIf Rows(i).Interior.Color = RGB(0, 0, 0) Then Exit Sub
Else: Rows(i).EntireRow.Delete
i = i - 1
DerCel = DerCel - 1
End If
Next i
Application.ScreenUpdating = True
Range("A1:J65535").Select
Selection.Sort Key1:=Range("J1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("J:J").Delete |
Partager