Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Find #Ref! and replace

How can i in code find alll cells that have #Ref! and replace it with 0?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200707/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Find #Ref! and replace

Assuming that would be the only error in the cells selected:

On Error Resume Next
Selection.SpecialCells(xlFormulas,xlErrors) = 0
On Error goto 0

--
Regards,
Tom Ogilvy


"jln via OfficeKB.com" wrote:

How can i in code find alll cells that have #Ref! and replace it with 0?

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200707/1


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Find #Ref! and replace

Tom like always it worked great.

Tom Ogilvy wrote:
Assuming that would be the only error in the cells selected:

On Error Resume Next
Selection.SpecialCells(xlFormulas,xlErrors) = 0
On Error goto 0

How can i in code find alll cells that have #Ref! and replace it with 0?


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200707/1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Find #Ref! and replace

How can i in code find alll cells that have #Ref! and replace it with 0?

Do this:

Cells.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False


Brian Herbert Withun

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Find #Ref! and replace

Just a heads up, but ift the #REF! is caused by a formula (and why else would
you have it), this method won't work.

If you select the cells and do edit=copy, then Edit=Paste Special Values,
then it will work.

--
Regards,
Tom Ogilvy


"Brian" wrote:

How can i in code find alll cells that have #Ref! and replace it with 0?


Do this:

Cells.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False


Brian Herbert Withun




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find #Ref! and replace

Another option based on Brian's suggestion:

Cells.Replace What:="*#REF!*", _
Replacement:="0", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False


Brian wrote:

How can i in code find alll cells that have #Ref! and replace it with 0?


Do this:

Cells.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False

Brian Herbert Withun


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Find #Ref! and replace

?????

--
Regards,
Tom Ogilvy


"Dave Peterson" wrote:

Another option based on Brian's suggestion:

Cells.Replace What:="*#REF!*", _
Replacement:="0", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False


Brian wrote:

How can i in code find alll cells that have #Ref! and replace it with 0?


Do this:

Cells.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False

Brian Herbert Withun


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find #Ref! and replace

I surrounded the #REF! with wildcards: *#REF!*

and in my tests, the cells that contained any #REF! errors were changed to 0's.

Or did you mean something else?

Tom Ogilvy wrote:

?????

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote:

Another option based on Brian's suggestion:

Cells.Replace What:="*#REF!*", _
Replacement:="0", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False


Brian wrote:

How can i in code find alll cells that have #Ref! and replace it with 0?

Do this:

Cells.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False

Brian Herbert Withun


--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Find #Ref! and replace

I mean I ran your code and it did nothing for me in a worksheet where #REF!
is produced by a formula. Replace looks at the formula in the cell

=someformula

and #REF! will not be found there unless someone has something goofy like

=if(True,"#REF!",";-)")

xl2003

I ran your macro on my sheet and got

#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
0 0 0 0 0
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!
#REF! #REF! #REF! #REF! #REF!

Guess which row I had done Edit=Copy, then Edit=Paste Special, then
values.

Maybe we are talking apples and oranges - enlighten me on "What I am
missing" as you might say. Because of your great wisdom, I hesitate to
question your suggestion, but in this case, I don't see it.

--
Regards,
Tom Ogilvy




"Dave Peterson" wrote:

I surrounded the #REF! with wildcards: *#REF!*

and in my tests, the cells that contained any #REF! errors were changed to 0's.

Or did you mean something else?

Tom Ogilvy wrote:

?????

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote:

Another option based on Brian's suggestion:

Cells.Replace What:="*#REF!*", _
Replacement:="0", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False


Brian wrote:

How can i in code find alll cells that have #Ref! and replace it with 0?

Do this:

Cells.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False

Brian Herbert Withun

--

Dave Peterson


--

Dave Peterson

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 - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
Find & Replace and Find & Insert macro help needed RS Excel Programming 2 January 29th 07 07:35 AM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM
Replace method - cannot find any data to replace Mike Excel Programming 5 April 6th 06 08:56 PM


All times are GMT +1. The time now is 06:17 AM.

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"