Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Automatically Changing Functions


I have over 720 functions across four worksheets that commonly results
in #Div/0 errors. I want to insert an "error handling" function to
make those #Div/0 errors disappear. That's the easy part. I am
using:

=IF(ISERROR(OriginalFormula),"",OriginalFormula)

-- "Original Function" could be as simple as: =((A1+A5)/(B1-B8))

My problem is that I don't want to manually go to each cell and cut,
paste, cut, paste, etc. to make the alterations to each formula.

Is there any macro that will make each "OriginalFormula" a variable,
and automatically paste the variable (original function) back into my
desired new function above?

Thanks....


--
bmstar
------------------------------------------------------------------------
bmstar's Profile: http://www.excelforum.com/member.php...o&userid=36264
View this thread: http://www.excelforum.com/showthread...hreadid=565888

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,073
Default Automatically Changing Functions


bmstar wrote:
I have over 720 functions across four worksheets that commonly results
in #Div/0 errors. I want to insert an "error handling" function to
make those #Div/0 errors disappear. That's the easy part. I am
using:

=IF(ISERROR(OriginalFormula),"",OriginalFormula)

-- "Original Function" could be as simple as: =((A1+A5)/(B1-B8))

My problem is that I don't want to manually go to each cell and cut,
paste, cut, paste, etc. to make the alterations to each formula.

Is there any macro that will make each "OriginalFormula" a variable,
and automatically paste the variable (original function) back into my
desired new function above?

Thanks....



Hi bmstar,

this worked for me...

Public Sub ChangeToHandleError()
Dim rngCell As Range
Dim strFormula As String
For Each rngCell In Application.Selection
If Left(rngCell.Formula, 1) = "=" Then
strFormula = Right(rngCell.Formula, Len(rngCell.Formula) - 1)
rngCell.Formula = "=IF(ISERROR(" & strFormula & _
"),""""," & strFormula & ")"
End If
Next
End Sub

It works on the range of cells that you select before running.

Try it out on a copy of your sheet first.

Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,073
Default Automatically Changing Functions


Hi bmstar,

just a minor improvement so that the code doesn't change any formulas
in the selected range that are already set up to hide the DIV0 error,
which results in unnecessarily long formulas...

Public Sub ChangeToHandleError()
Dim rngCell As Range
Dim strFormula As String
For Each rngCell In Application.Selection
If Left(rngCell.Formula, 1) = "=" _
And Left(rngCell.Formula, 11) < "=IF(ISERROR" Then
strFormula = Right(rngCell.Formula, Len(rngCell.Formula) - 1)
rngCell.Formula = "=IF(ISERROR(" & strFormula & _
"),""""," & strFormula & ")"
End If
Next
End Sub

Ken Johnson

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
Find and replace - problem with automatically changing formatting jwa90010 Excel Discussion (Misc queries) 6 October 28th 08 08:07 PM
Automatically changing cell information BBurz Excel Discussion (Misc queries) 3 July 12th 06 03:15 PM
Automatically filling date of today (without it changing tomorrow) Jaydubs Excel Discussion (Misc queries) 5 June 27th 06 05:11 PM
How do I stop Excel from automatically changing font size? SK Excel Discussion (Misc queries) 0 June 22nd 06 03:13 PM
Automatically changing stock tick quotes to decimal-price format. Kaci Excel Worksheet Functions 1 June 15th 05 04:53 PM


All times are GMT +1. The time now is 11:18 AM.

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"