Auto Format Excel Cells with Error Value

With the simple Excel macro below, we can make all cells in active Worksheet that contains Error value in it, like #NULL, #Div/0!, #VALUE!, #Ref, #NAME?, #NUM!, And #N/A, will automatically having cell format that different/stand out among all other cells.

In this example, background color of the cell that contains the error value will automatically change color to red, each time the Excel Worksheet activated.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim errCells As Range

Set errCells = Cells.SpecialCells(xlCellTypeFormulas, xlErrors)
errCells.Interior.Color = 255

Set errCells = Nothing
End Sub

Note that using the Cells.SpeciallCells function, we do not need to perform any looping to get Cells which contains the Error value.

This is just like automating Excel cell conditional formating process. Instead of selecting manually all the cells contains Error value or select all cells and then performing cell conditional format, with above code, we do it automatically using simple Excel VBA macro.

This entry was posted in Cells and Range and tagged , , , , , . Bookmark the permalink.

1,775 Responses to Auto Format Excel Cells with Error Value

  1. Pingback: promotion

  2. Pingback: adele

  3. Pingback: dentist brooklyn ny

  4. Pingback: Burnaby SEO

  5. Pingback: Eugene

  6. Pingback: kitchen design review

  7. Pingback: click here

  8. Pingback: cheap printing

  9. Pingback: achat produit naturel

  10. Pingback: Penny Auction Sites

  11. Pingback: seyari

  12. Pingback: wieprz

  13. Pingback: jocuripentrucopii

  14. Pingback: radio echo

  15. Pingback: kwik98

  16. Pingback: matma matura

  17. Pingback: TM

  18. Pingback: radio hit

  19. Pingback: scrapebox list

  20. Pingback: praying hands

  21. Pingback: Symbol LS7808 Barcode Scanner

  22. Pingback: servis char

  23. Pingback: diabetic bags

  24. Pingback: alpharetta tree service

  25. Pingback: mansfield tx private schools

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>