VBA to Highlight #N/A in dynamic range dataset

TheHack22

Board Regular
Joined
Feb 3, 2021
Messages
121
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi VBA Experts.
I have looked everywhere but can't seem to find a VBA Sub to find and highlight #N/A in a dataset if any exist.
The dataset is hardcoded data formatted as general. I even try to record a macro to do this, but the recorder doesn't record the "Find & Replace" box activities.

Any help with this is greatly appreciated.
Imran
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Must it be VBA? A nice conditional formatting formula with
MrExcelPlayground6.xlsx
H
55
6#N/A
73
84
9#N/A
Sheet12
Cell Formulas
RangeFormula
H6,H9H6=NA()
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H5:H9Expression=ISNA(H5)textNO
 
Upvote 0
This will highlight all error values, not just #N/A
VBA Code:
Sub Imran()
   On Error Resume Next
   ActiveSheet.UsedRange.SpecialCells(xlConstants, xlErrors).Interior.Color = 255
   On Error GoTo 0
End Sub
 
Upvote 0
Solution
Must it be VBA? A nice conditional formatting formula with
MrExcelPlayground6.xlsx
H
55
6#N/A
73
84
9#N/A
Sheet12
Cell Formulas
RangeFormula
H6,H9H6=NA()
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H5:H9Expression=ISNA(H5)textNO
@JamesCanale

Thanks for your response. I would like to have this done VIA VBA. Because this is not a static file, every day a new consolidated data file is created from scratch(May have "#N/A"). It will be very "time-consuming and tedious" to do this every time. All the manual processes add up. I have automated 99% of the manual steps for this daily process. This is the last one I'm trying to automate.
 
Upvote 0
This will highlight all error values, not just #N/A
VBA Code:
Sub Imran()
   On Error Resume Next
   ActiveSheet.UsedRange.SpecialCells(xlConstants, xlErrors).Interior.Color = 255
   On Error GoTo 0
End Sub
@Fluff
This is beautiful - did exactly what I wanted it to do.
I have searched so many places and couldn't find an answer. You're awesome. You saved me a lot of headaches.
Imran
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

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