本帖最后由 dadasdas 于 2013-2-17 19:44 编辑
帮忙精简下代码?
Sub test()
For i = 5 To Range("H" & Rows.Count).End(3).Row
If Cells(i, 8).Interior.ColorIndex = 40 And Cells(i, 8) <> "" Then
Cells(i, 30) = Cells(i, 8).Value
Cells(i, 31) = 10: Cells(i, 21) = "1": Cells(i, 23) = "2": Cells(i, 26) = "d"
Cells(i, 32) = Cells(i, 31) * Cells(i, 30)
ElseIf Cells(i, 8).Interior.ColorIndex = 44 And Cells(i, 8) <> "" Then
Cells(i, 30) = Cells(i, 8).Value
Cells(i, 31) = 50: Cells(i, 21) = "1": Cells(i, 23) = "2": Cells(i, 26) = "b"
Cells(i, 32) = Cells(i, 31) * Cells(i, 30)
ElseIf Cells(i, 8).Interior.ColorIndex = 45 And Cells(i, 8) <> "" Then
Cells(i, 30) = Cells(i, 8).Value
Cells(i, 31) = 60: Cells(i, 21) = "1": Cells(i, 23) = "2": Cells(i, 26) = "c"
Cells(i, 32) = Cells(i, 31) * Cells(i, 30)
ElseIf Cells(i, 8).Interior.ColorIndex = 46 And Cells(i, 8) <> "" Then
Cells(i, 30) = Cells(i, 8).Value
Cells(i, 31) = 70: Cells(i, 21) = "1": Cells(i, 23) = "2": Cells(i, 26) = "a"
Cells(i, 32) = Cells(i, 31) * Cells(i, 30)
End If
Next
End Sub
|