Sub tt() Dim i& For i = 1 To ActiveSheet.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row If Cells(i, 22) = "male" Then Cells(i, 21).Interior.Color = 15652797 If Cells(i, 22) = "female" Then Cells(i, 21).Interior.Color = 11389944 If Cells(i, 22) = "mix" Then Cells(i, 21).Interior.Color = 10086143 If Cells(i, 24) = "male" Then Cells(i, 23).Interior.Color = 15652797 If Cells(i, 24) = "female" Then Cells(i, 23).Interior.Color = 11389944 If Cells(i, 24) = "mix" Then Cells(i, 23).Interior.Color = 10086143 If Cells(i, 26) = "male" Then Cells(i, 25).Interior.Color = 15652797 If Cells(i, 26) = "female" Then Cells(i, 25).Interior.Color = 11389944 If Cells(i, 26) = "mix" Then Cells(i, 25).Interior.Color = 10086143 Next End Sub
[/vba]
Правильный файл
Сам макрос:
[vba]
Код
Sub tt() Dim i& For i = 1 To ActiveSheet.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row If Cells(i, 22) = "male" Then Cells(i, 21).Interior.Color = 15652797 If Cells(i, 22) = "female" Then Cells(i, 21).Interior.Color = 11389944 If Cells(i, 22) = "mix" Then Cells(i, 21).Interior.Color = 10086143 If Cells(i, 24) = "male" Then Cells(i, 23).Interior.Color = 15652797 If Cells(i, 24) = "female" Then Cells(i, 23).Interior.Color = 11389944 If Cells(i, 24) = "mix" Then Cells(i, 23).Interior.Color = 10086143 If Cells(i, 26) = "male" Then Cells(i, 25).Interior.Color = 15652797 If Cells(i, 26) = "female" Then Cells(i, 25).Interior.Color = 11389944 If Cells(i, 26) = "mix" Then Cells(i, 25).Interior.Color = 10086143 Next End Sub