Pete and Andy's responses prompted me to try a little VBA.
The procedure below works in two steps:
1. Converts all formulas in user specified column to their values
2. Check eaach cell in user column to see if it is an error (#N/A. etc.)
if error, clears contents.
The result is a dataset with just values. You can then use Excel's plot
empty cells to handle blanks the way you want.
Any thoughts?
...Kelly
[email protected]
Public Sub Chart_If_Na_conversion()
' ================================================================
' D. Kelly ODay - ProcessTrends.com
'Charting Cells with if Formulas can be a nuisance
' The If Na() work around solves part of problem - eliminates Excel plotting
blanks as zeros
' Excel interpolates values when it sees #N/A - not necessarily what user
wants
' This procedure converts formulas to their values
' Then converts all #N/As to true empty cells
' Ask user for column to convert
'=================================================================
Set st = Application.InputBox("Select column to convert formula to value",
"Convert Formula to Value", Type:=8)
st.Select
cl = ActiveCell.Column
last_row = Cells(Rows.Count, cl).End(xlUp).Row
' Convert all formulas to values
Set temp_rng = Range(Cells(1, cl), Cells(last_row, cl))
temp_rng.Copy
Cells(1, cl).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Clearcotnents of all error values
For r = 1 To last_row
celltype = ""
If IsError(Cells(r, cl).Value) Then
errval = Cells(r, cl).Value
Select Case errval
Case CVErr(xlErrDiv0): celltype = "Error"
Case CVErr(xlErrNA): celltype = "Error"
Case CVErr(xlErrName): celltype = "Error"
Case CVErr(xlErrNull): cellstype = "Error"
Case CVErr(xlErrNum): celltype = "Error"
Case CVErr(xlErrRef): celltype = "Error"
Case CVErr(xlErrValue): celltype = "Error"
End Select
End If
If celltype = "Error" Then Cells(r, cl).ClearContents
Next r
End Sub