VBA - Condition formating based on condition

Status
Not open for further replies.

kipulbiu

New Member
Joined
Aug 14, 2016
Messages
37
Good evening,

I have a column C3 in which I enter a value and a range (BU:CI) in which I also enter a value for each column.
For each row (10000) I would like a macro to copy the formtting ( interior and font ) of C3 value if this value is the same in the Range (BU:CI)

I have tried to write the following code. It works for the first one but when I add to it does not work any longer.

Could you please help?

Thanks in advance

Bruno


Private Sub CommandButton1_Click()
Dim i As Integer


For i = 3 To 10000


If Cells(i, 3).Value = Cells(i, 73).Value Then
Cells(i, 73).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 73).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 74).Value Then
Cells(i, 74).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 74).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 75).Value Then
Cells(i, 75).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 75).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 76).Value Then
Cells(i, 76).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 76).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 77).Value Then
Cells(i, 77).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 77).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 78).Value Then
Cells(i, 78).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 78).Font.Color = Cells(i, 3).Font.Color




If Cells(i, 3).Value = Cells(i, 79).Value Then
Cells(i, 79).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 79).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 80).Value Then
Cells(i, 80).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 80).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 81).Value Then
Cells(i, 81).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 81).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 82).Value Then
Cells(i, 82).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 82).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 82).Value Then
Cells(i, 83).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 83).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 82).Value Then
Cells(i, 84).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 84).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 85).Value Then
Cells(i, 85).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 85).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 86).Value Then
Cells(i, 86).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 86).Font.Color = Cells(i, 3).Font.Color


If Cells(i, 3).Value = Cells(i, 87).Value Then
Cells(i, 87).Interior.ColorIndex = Cells(i, 3).Interior.ColorIndex
Cells(i, 87).Font.Color = Cells(i, 3).Font.Color


End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If






Next i




End Sub
 
Last edited:
@kipulbiu
Please do not ask the same question multiple times.
This thread is now closed.
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Status
Not open for further replies.

Forum statistics

Threads
1,224,746
Messages
6,180,705
Members
452,994
Latest member
Janick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top