I am trying to compare two columns on the same sheet.

Status
Not open for further replies.

pveke

New Member
Joined
Sep 12, 2020
Messages
9
Office Version
  1. 2013
Platform
  1. Windows
Such that if column A has the entry Escalation Standby and column B has the entry Absent then column B should be formatted with a red colour otherwise green. I kept getting different errors one being compile error. Kindly assist



Sub conditional_formatting()
Dim aRng, bRng As Range
Set aRng = Range("AC5:A175")
Set bRng = Range("AD5:AD175")

For Each acell In aRng
For Each bcell In bRng
If acell Like "Escalation Standby" And bcell Like "Absent" Then
bcell.Interior.ColourIndex = 3
Else: bcell.Interior.ColourIndex = 10
End If
Next
Next
For Each ccell In aRng
For Each dcell In bRng
If ccell = "Standby" And dcell = "Absent" Then
dcell.Interior.ColourIndex = 3
Else: dcell.Interior.ColourIndex = 10
End If
Next
Next
For Each ecell In aRng
For Each fcell In bRng
If ecell Like "Attend" And fcell Like "Attend" Then
fcell.Interior.ColourIndex = 10
Else: fcell.Interior.ColourIndex = 3
End If
Next
Next
For Each gcell In aRng
For Each hcell In bRng
If gcell Like "N/A" Then
hcell.Interior.ColourIndex = 10
End If
Next
Next
For Each icell In aRng
For Each jcell In bRng
If jcell Like "Absent" Then
jcell.Interior.ColourIndex = 3
End If

Next
Next

End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Status
Not open for further replies.

Forum statistics

Threads
1,226,475
Messages
6,191,226
Members
453,648
Latest member
graduateguardian

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