View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
sck10 sck10 is offline
external usenet poster
 
Posts: 4
Default catching "#DIV/0!" in a loop

Thank you Bernie,

This helps greatly...

sck10


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Forget the loop, just use

Range("rng_test").Replace Chr(10), " "
Range("rng_test").Replace Chr(13), " "

HTH,
Bernie
MS Excel MVP


"sck10" wrote in message
...
Hello,

I am running the following to replace "alt+Enter". Whenever I run across
a cell with the value of "#DIV/0!" I get an error (Error = 2007). What
I don't understand is that the "#DIV/0!" is not a equation, but a value.
Any help with this would be appreciated.

Thanks, sck10


Range("rng_test").Select
Dim myCell As Range
'For Each myCell In Range("rng_template").Cells
For Each myCell In Selection.Cells
Range("rng_value").Value = myCell.Value

End If
If myCell.Value = "#DIV/0!" Then
myCell.Value = ""
End If

myCell.Value = Replace(myCell.Value, Chr(10), " ")
myCell.Value = Replace(myCell.Value, Chr(13), " ")
Next