A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

macro - replace



 
 
Thread Tools Display Modes
  #1  
Old March 26th, 2010, 04:11 AM posted to microsoft.public.excel.newusers
ROHIT
external usenet poster
 
Posts: 36
Default macro - replace

hi, i have various worksheets and within that worksheet there are cells
having #DIV/0!. I want this to be replace by zero. i know there is a
formula which will give out zero but if someone can write a macro would good.

Thanks
  #2  
Old March 26th, 2010, 04:39 AM posted to microsoft.public.excel.newusers
Gord Dibben
external usenet poster
 
Posts: 20,252
Default macro - replace

Sub ErrorTrapAdd()
Dim mystr As String
Dim cel As Range
For Each cel In Selection
If cel.HasFormula = True Then
If Not cel.Formula Like "=IF(ISERROR*" Then
mystr = Right(cel.Formula, Len(cel.Formula) - 1)
cel.Value = "=IF(ISERROR(" & mystr & "),0," & mystr & ")"
End If
End If
Next
End Sub


Gord Dibben MS Excel MVP

On Thu, 25 Mar 2010 20:11:01 -0700, Rohit
wrote:

hi, i have various worksheets and within that worksheet there are cells
having #DIV/0!. I want this to be replace by zero. i know there is a
formula which will give out zero but if someone can write a macro would good.

Thanks


  #3  
Old March 26th, 2010, 05:19 AM posted to microsoft.public.excel.newusers
FSt1
external usenet poster
 
Posts: 2,788
Default macro - replace

hi
the formula is the microsoft way of dealing with the problem.
see this site.
http://support.microsoft.com/kb/182188
i know of no macro command that would make the #DEV/0! error go away other
than to replace the formula with zero or replace the formula with the above
formula.

regards
FSt1

"Rohit" wrote:

hi, i have various worksheets and within that worksheet there are cells
having #DIV/0!. I want this to be replace by zero. i know there is a
formula which will give out zero but if someone can write a macro would good.

Thanks

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:09 PM.


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