Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Replace formula with IF(error(formula;"";formula)


Hi all

Do you think is there any macro that can change the formula in selected
range to include the IF-iserror so no error appears on the screen?

For example:
In cell A1 the formula is: =A2+B2
But if I select A1 and run the macro, It would change to:
=IF(ISERROR(A2+B2);"";(A2+B2))

I need that beacause I have a sheet with lots of formulas with different
errors and It would be quite painful to chang every formula.

Thanks you for your help!!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Replace formula with IF(error(formula;"";formula)


I have found the answer:

Sub ErrorTrapAddDDL()

' Adds =If(IsError() around formulas

Dim cel As Range
Dim rng As Range
Dim Check As String

Const Equ As String = "=IF(ISERROR(_x) ,"""", _x)"

Check = Left$(Equ, 12) & "*" ' Check for =IF(ISERROR(

On Error Resume Next

Set rng = Selection.SpecialCells(xlFormulas, 23)
If rng Is Nothing Then Exit Sub

With WorksheetFunction
For Each cel In rng
If Not cel.Formula Like Check Then
cel.Formula = .Substitute(Equ, "_x", Mid$(cel.Formula, 2))
End If
Next
End With
End Sub


Thanks anyway!

"lecaballero" escribió:


Hi all

Do you think is there any macro that can change the formula in selected
range to include the IF-iserror so no error appears on the screen?

For example:
In cell A1 the formula is: =A2+B2
But if I select A1 and run the macro, It would change to:
=IF(ISERROR(A2+B2);"";(A2+B2))

I need that beacause I have a sheet with lots of formulas with different
errors and It would be quite painful to chang every formula.

Thanks you for your help!!!!

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
While using find and replace i am getting "formula too long" venkat Excel Discussion (Misc queries) 4 November 26th 06 01:24 PM
How do I replace a "#N/A" formula result with a blank in excel? yrat Excel Discussion (Misc queries) 6 April 3rd 06 04:38 AM
How do I replace "#N/A" error, to continue my formula w/o error? Ali Khan Excel Worksheet Functions 2 February 20th 06 03:49 PM
Can you replace "TRUE" with " " in an exact formula? Sweetetc Excel Worksheet Functions 2 February 10th 06 01:11 PM
I get error with "ROWS" in the formula - nested formula question Marie J-son Excel Worksheet Functions 0 January 4th 06 01:55 PM


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

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

About Us

"It's about Microsoft Excel"