PC Review


Reply
Thread Tools Rate Thread

Auto IsError

 
 
=?Utf-8?B?V0JUS2JlZXp5?=
Guest
Posts: n/a
 
      21st Nov 2007
Hello:

I found this code online from Microsoft that automatically changes a formula
to an ISERROR formula using your original formula...

http://support.microsoft.com/kb/213387

It works awesome, but it only does one cell at a time. I have been trying,
with little success, to make it work so I can select a section and it will
work through the whole thing. Can anyone provide assistance?

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      21st Nov 2007
This is the suggested code:

Sub ErrorToZero()
X = Right(ActiveCell.Formula,Len(ActiveCell.Formula)-1)
ActiveCell.Formula = "=IF(ISERROR(" & X & "),0," & X & ")"
End Sub

I'd use:

Option Explicit
Sub ErrorToZero2()
Dim myRng As Range
Dim myCell As Range
Dim myStr As String

Set myRng = Nothing
On Error Resume Next
Set myRng = Intersect(Selection, _
Selection.Cells.SpecialCells(xlCellTypeFormulas))
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "No formulas in selection!"
Exit Sub
End If

For Each myCell In myRng.Cells
myStr = Mid(myCell.Formula, 2)
myCell.Formula = "=If(iserror(" & myStr & "),0," & myStr & ")"
Next myCell

End Sub



WBTKbeezy wrote:
>
> Hello:
>
> I found this code online from Microsoft that automatically changes a formula
> to an ISERROR formula using your original formula...
>
> http://support.microsoft.com/kb/213387
>
> It works awesome, but it only does one cell at a time. I have been trying,
> with little success, to make it work so I can select a section and it will
> work through the whole thing. Can anyone provide assistance?


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?V0JUS2JlZXp5?=
Guest
Posts: n/a
 
      21st Nov 2007
That is perfect, Dave, Thanks!

The Error Handler is a nice touch as well.

"Dave Peterson" wrote:

> This is the suggested code:
>
> Sub ErrorToZero()
> X = Right(ActiveCell.Formula,Len(ActiveCell.Formula)-1)
> ActiveCell.Formula = "=IF(ISERROR(" & X & "),0," & X & ")"
> End Sub
>
> I'd use:
>
> Option Explicit
> Sub ErrorToZero2()
> Dim myRng As Range
> Dim myCell As Range
> Dim myStr As String
>
> Set myRng = Nothing
> On Error Resume Next
> Set myRng = Intersect(Selection, _
> Selection.Cells.SpecialCells(xlCellTypeFormulas))
> On Error GoTo 0
>
> If myRng Is Nothing Then
> MsgBox "No formulas in selection!"
> Exit Sub
> End If
>
> For Each myCell In myRng.Cells
> myStr = Mid(myCell.Formula, 2)
> myCell.Formula = "=If(iserror(" & myStr & "),0," & myStr & ")"
> Next myCell
>
> End Sub
>
>
>
> WBTKbeezy wrote:
> >
> > Hello:
> >
> > I found this code online from Microsoft that automatically changes a formula
> > to an ISERROR formula using your original formula...
> >
> > http://support.microsoft.com/kb/213387
> >
> > It works awesome, but it only does one cell at a time. I have been trying,
> > with little success, to make it work so I can select a section and it will
> > work through the whole thing. Can anyone provide assistance?

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ISERROR Jim Microsoft Excel Programming 3 1st Oct 2008 07:10 PM
Help with ISERROR juliejg1 Microsoft Excel Worksheet Functions 2 18th Dec 2007 09:48 PM
iserror help Scott@CW Microsoft Excel Worksheet Functions 1 13th Dec 2007 06:03 PM
Iserror & VBA =?Utf-8?B?S2VuIEcu?= Microsoft Excel Misc 1 28th Feb 2006 11:37 PM
IF(ISERROR(????) Nigel Graham Microsoft Excel Worksheet Functions 3 28th Nov 2003 03:42 AM


Features
 

Advertising
 

Newsgroups
 


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