Highlight cells on column B based on the content of cells in Column E

ShirinB

New Member
Joined
Jul 21, 2014
Messages
6
Hi,

I was a Macro that help me to highlight parallel cells in column B IF cells in column E containing #N/A.
So if a cell in column E row 3 is #N/A I want column B row 3 gets highlighted.


Regards,
Shirin
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You can apply conditional formatting to column B with formula =ISNA($E1)

Hi,

Could please let me know which Conditional formatting I need to use?
I picked a "New rule" and then "Use a formula to determine which cells to format" However, it does not highlight anything in Column B.


Regards,
Shirin
 
Upvote 0
If you have a hard time with conditional formatting, Try this
Code:
Sub t()
Dim sh As Worksheet, rng As Range
Set sh = ActiveSheet
Set rng = Intersect(sh.UsedRange, Range("B:B"))
sh.UsedRange.AutoFilter 5, "=#N/A"
rng.SpecialCells(xlCellTypeVisible).Interior.ColorIndex = 6
sh.AutoFilterMode = False
End Sub
 
Upvote 0
Here's another macro (though as it involves looping isn't as good as JLGWhiz's propsed solution):

Code:
Option Explicit
Sub Macro1()
    
    Dim lngLastRow As Long, lngMyRow As Long
   
    Application.ScreenUpdating = False
    
    lngLastRow = Cells(Rows.Count, "E").End(xlUp).Row
    
    For lngMyRow = 1 To lngLastRow
        If IsError(Range("E" & lngMyRow)) = True Then
            If Range("E" & lngMyRow).Value = CVErr(xlErrNA) Then 'ONLY '#N/A' errors will be flagged. Change to suit if necessary.
                Range("B" & lngMyRow).Interior.Color = RGB(255, 0, 0)
            End If
        End If
    Next lngMyRow
    
    Application.ScreenUpdating = True
    
    MsgBox "All rows in Col. B where there is a #N/A error in Col. E have been filled red.", vbInformation
    
End Sub

Regards,

Robert
 
Upvote 0
If you have a hard time with conditional formatting, Try this
Code:
Sub t()
Dim sh As Worksheet, rng As Range
Set sh = ActiveSheet
Set rng = Intersect(sh.UsedRange, Range("B:B"))
sh.UsedRange.AutoFilter 5, "=#N/A"
rng.SpecialCells(xlCellTypeVisible).Interior.ColorIndex = 6
sh.AutoFilterMode = False
End Sub
Hi,

This worked fine. :):):)

Thank you very much.

Regards,
Shirin
 
Upvote 0
Hi,

Could please let me know which Conditional formatting I need to use?
I picked a "New rule" and then "Use a formula to determine which cells to format" However, it does not highlight anything in Column B.


Regards,
Shirin

Apologies. Definining the formula is one step, chosing "Format" and pick your choices would be the 2nd step.
 
Upvote 0

Forum statistics

Threads
1,216,066
Messages
6,128,571
Members
449,458
Latest member
gillmit

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