Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Formatting

Is it possible to conditionally format a cell that has a value of #DIV/
0?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Conditional Formatting

I don't think so. You can signal any error condition by using ISERROR(A1),
or just ISERR(A1) if you don't care about #NA errors, as your Conditional
Formatting formula, but I don't think you can narrow it down to just the
#DIV/0! error. I would think you should be able to use Event code to mimic
the behavior of Conditional Formatting if a VB solution is acceptable.

--
Rick (MVP - Excel)



"hotplate" wrote in message
...
Is it possible to conditionally format a cell that has a value of #DIV/
0?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Conditional Formatting

The following event code should do what I said (mimic Conditional Formatting
for #DIV/0! errors only). Note that, as written, it looks for these errors
in Columns A and B only (this can be changed to another column or an
arbitrary range if needed by changing the address assigned to the Addr
constant in the code); and the code assumes there are formulas in Column B
(that is, the assumption is that your user didn't simply type =2/0 into a
cell in Column B, but rather, a formula in that column evaluated to the
error).

Private Sub Worksheet_Change(ByVal Target As Range)
Dim R As Range
Const Addr As String = "A:B"
On Error GoTo SkipIt
For Each R In Target.Dependents
If Not Intersect(Range(Addr), R) Is Nothing Then
R.Interior.ColorIndex = xlNone
If IsError(R.Value) Then
If R.Value = CVErr(2007) Then R.Interior.ColorIndex = 3
End If
End If
Next
SkipIt:
End Sub

You would install this event code by right-clicking the tab at the bottom of
the worksheet you want to have this functionality, selecting View Code from
the popup menu that appears and then copy/pasting the above code into the
code window that opened up.

--
Rick (MVP - Excel)



"Rick Rothstein" wrote in message
...
I don't think so. You can signal any error condition by using ISERROR(A1),
or just ISERR(A1) if you don't care about #NA errors, as your Conditional
Formatting formula, but I don't think you can narrow it down to just the
#DIV/0! error. I would think you should be able to use Event code to mimic
the behavior of Conditional Formatting if a VB solution is acceptable.

--
Rick (MVP - Excel)



"hotplate" wrote in message
...
Is it possible to conditionally format a cell that has a value of #DIV/
0?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Conditional Formatting

Don't know if this works in 2003, but in 2007 you can use this as your
formula (assumes the #DIV is in A1):

=If(ERROR.TYPE(A1)=2,1,0)=1

Then set the fill to red or whatever conditional format you want!

From Excel Help:

If error_val is ERROR.TYPE returns
#NULL! 1
#DIV/0! 2
#VALUE! 3
#REF! 4
#NAME? 5
#NUM! 6
#N/A 7
Anything else #N/A

HTH,

Eric

"Rick Rothstein" wrote:

The following event code should do what I said (mimic Conditional Formatting
for #DIV/0! errors only). Note that, as written, it looks for these errors
in Columns A and B only (this can be changed to another column or an
arbitrary range if needed by changing the address assigned to the Addr
constant in the code); and the code assumes there are formulas in Column B
(that is, the assumption is that your user didn't simply type =2/0 into a
cell in Column B, but rather, a formula in that column evaluated to the
error).

Private Sub Worksheet_Change(ByVal Target As Range)
Dim R As Range
Const Addr As String = "A:B"
On Error GoTo SkipIt
For Each R In Target.Dependents
If Not Intersect(Range(Addr), R) Is Nothing Then
R.Interior.ColorIndex = xlNone
If IsError(R.Value) Then
If R.Value = CVErr(2007) Then R.Interior.ColorIndex = 3
End If
End If
Next
SkipIt:
End Sub

You would install this event code by right-clicking the tab at the bottom of
the worksheet you want to have this functionality, selecting View Code from
the popup menu that appears and then copy/pasting the above code into the
code window that opened up.

--
Rick (MVP - Excel)



"Rick Rothstein" wrote in message
...
I don't think so. You can signal any error condition by using ISERROR(A1),
or just ISERR(A1) if you don't care about #NA errors, as your Conditional
Formatting formula, but I don't think you can narrow it down to just the
#DIV/0! error. I would think you should be able to use Event code to mimic
the behavior of Conditional Formatting if a VB solution is acceptable.

--
Rick (MVP - Excel)



"hotplate" wrote in message
...
Is it possible to conditionally format a cell that has a value of #DIV/
0?


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Conditional Formatting

Yes, very good... that works fine in XL2003. For some reason ERROR.TYPE just
didn't come to mind when I read this question initially. Thanks for jumping
in with that... it should be exactly what the OP wants.

--
Rick (MVP - Excel)



"EricG" wrote in message
...
Don't know if this works in 2003, but in 2007 you can use this as your
formula (assumes the #DIV is in A1):

=If(ERROR.TYPE(A1)=2,1,0)=1

Then set the fill to red or whatever conditional format you want!

From Excel Help:

If error_val is ERROR.TYPE returns
#NULL! 1
#DIV/0! 2
#VALUE! 3
#REF! 4
#NAME? 5
#NUM! 6
#N/A 7
Anything else #N/A

HTH,

Eric

"Rick Rothstein" wrote:

The following event code should do what I said (mimic Conditional
Formatting
for #DIV/0! errors only). Note that, as written, it looks for these
errors
in Columns A and B only (this can be changed to another column or an
arbitrary range if needed by changing the address assigned to the Addr
constant in the code); and the code assumes there are formulas in Column
B
(that is, the assumption is that your user didn't simply type =2/0 into a
cell in Column B, but rather, a formula in that column evaluated to the
error).

Private Sub Worksheet_Change(ByVal Target As Range)
Dim R As Range
Const Addr As String = "A:B"
On Error GoTo SkipIt
For Each R In Target.Dependents
If Not Intersect(Range(Addr), R) Is Nothing Then
R.Interior.ColorIndex = xlNone
If IsError(R.Value) Then
If R.Value = CVErr(2007) Then R.Interior.ColorIndex = 3
End If
End If
Next
SkipIt:
End Sub

You would install this event code by right-clicking the tab at the bottom
of
the worksheet you want to have this functionality, selecting View Code
from
the popup menu that appears and then copy/pasting the above code into the
code window that opened up.

--
Rick (MVP - Excel)



"Rick Rothstein" wrote in message
...
I don't think so. You can signal any error condition by using
ISERROR(A1),
or just ISERR(A1) if you don't care about #NA errors, as your
Conditional
Formatting formula, but I don't think you can narrow it down to just
the
#DIV/0! error. I would think you should be able to use Event code to
mimic
the behavior of Conditional Formatting if a VB solution is acceptable.

--
Rick (MVP - Excel)



"hotplate" wrote in message
...
Is it possible to conditionally format a cell that has a value of
#DIV/
0?

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I convert conditional formatting into explicit formatting? Patrick Harris Excel Discussion (Misc queries) 0 April 9th 09 12:00 AM
Conditional formatting--different formatting depending on cell con Tammy S. Excel Discussion (Misc queries) 3 March 30th 09 08:11 PM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
conditional Formatting based on cell formatting Totom Excel Worksheet Functions 3 January 20th 07 02:02 PM
Conditional Formatting that will display conditional data BrainFart Excel Worksheet Functions 1 September 13th 05 05:45 PM


All times are GMT +1. The time now is 08:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"