Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Find and delete error value

Hi,

I need a macro that can find the error value "#I/T" in the range A1:D10 and
clear the contents.
I tried this one below, but it didn't work, so I hope someone can correct it
or write a complete different macro doing the same thing.
Sub CheckCell()
Dim rCell As Range
Dim sMyString As String

Set rCell = Range("A1:D10")

If IsError(rCell.Value) Then

Cell.ClearContents

End If
End Sub

Regards,
Kaj Pedersen


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Find and delete error value

Hi Kaj,

Am Sun, 2 Oct 2011 19:09:58 +0200 schrieb KP:

I need a macro that can find the error value "#I/T" in the range A1:D10 and
clear the contents.


try:
Dim myRange As Range
Set myRange = Range("A1:D10")
myRange.SpecialCells(xlCellTypeFormulas, 16).ClearContents


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Find and delete error value

Hi Claus,

I have just tried your suggestion.
Unfortunately it resulted in Runtime Error 1004 (No cells were found)
Are you able to figure out what the problem is?

Kaj Pedersen


"Claus Busch" skrev i en meddelelse
...
Hi Kaj,

Am Sun, 2 Oct 2011 19:09:58 +0200 schrieb KP:

I need a macro that can find the error value "#I/T" in the range A1:D10
and
clear the contents.


try:
Dim myRange As Range
Set myRange = Range("A1:D10")
myRange.SpecialCells(xlCellTypeFormulas, 16).ClearContents


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Find and delete error value

Hi Kaj,

Am Sun, 2 Oct 2011 19:38:10 +0200 schrieb KP:

I have just tried your suggestion.
Unfortunately it resulted in Runtime Error 1004 (No cells were found)
Are you able to figure out what the problem is?


if the error value is not a result of a formula, change the code from
xlCellTypeFormulas to xlCellTypeConstants:

myRange.SpecialCells(xlCellTypeConstants, 16).ClearContents


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Find and delete error value

Hi Claus,

I am very happy about your new suggestion.
Now it works as I want.
Your help is very much appreciated.

Best regards,
Kaj Pedersen



"Claus Busch" skrev i en meddelelse
...
Hi Kaj,

Am Sun, 2 Oct 2011 19:38:10 +0200 schrieb KP:

I have just tried your suggestion.
Unfortunately it resulted in Runtime Error 1004 (No cells were found)
Are you able to figure out what the problem is?


if the error value is not a result of a formula, change the code from
xlCellTypeFormulas to xlCellTypeConstants:

myRange.SpecialCells(xlCellTypeConstants, 16).ClearContents


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Find and delete error value

I am very happy about your new suggestion.
Now it works as I want.


Really? It works? Exactly what is in your cells? You said your "error" was
#I/T... since #I/T is not a "real" Excel error, I don't see how Claus' code
could do what you want. Anyway, if your cells really have #I/T in them (as
constants, not formulas), then this code should replace each one of them
with the empty string, thus clearing those cells...

Sub ClearErrorIT()
Range("A1:D10").Replace "#I/T", "", xlWhole
End Sub

Rick Rothstein (MVP - Excel)

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Find and delete error value

You didn't say if there was more than ONE. If only one just use FIND

Sub FindString()
On Error Resume Next 'GoTo 0
With Worksheets("sheet9").Range("a1:d50")
Set c = .Find(What:="#I/T", LookIn:=xlValues, _
lookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Do
MsgBox c.address 'Row
c.Clear
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub




On Oct 2, 12:09*pm, "KP" <none wrote:
Hi,

I need a macro that can find the error value "#I/T" in the range A1:D10 and
clear the contents.
I tried this one below, but it didn't work, so I hope someone can correct it
or write a complete different macro doing the same thing.
Sub CheckCell()
Dim rCell As Range
Dim sMyString As String

Set rCell = Range("A1:D10")

If IsError(rCell.Value) Then

Cell.ClearContents

End If
End Sub

Regards,
Kaj Pedersen


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Find and delete error value

I am sorry about the insufficient information.
Actually there is more than one.
Do you have another suggestion?

Kaj Pedersen


"Don Guillett" skrev i en meddelelse
...
You didn't say if there was more than ONE. If only one just use FIND

Sub FindString()
On Error Resume Next 'GoTo 0
With Worksheets("sheet9").Range("a1:d50")
Set c = .Find(What:="#I/T", LookIn:=xlValues, _
lookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Do
MsgBox c.address 'Row
c.Clear
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub




On Oct 2, 12:09 pm, "KP" <none wrote:
Hi,

I need a macro that can find the error value "#I/T" in the range A1:D10
and
clear the contents.
I tried this one below, but it didn't work, so I hope someone can correct
it
or write a complete different macro doing the same thing.
Sub CheckCell()
Dim rCell As Range
Dim sMyString As String

Set rCell = Range("A1:D10")

If IsError(rCell.Value) Then

Cell.ClearContents

End If
End Sub

Regards,
Kaj Pedersen



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
Error dialog box meaning and how to find error Jeanne Excel Worksheet Functions 2 September 4th 08 04:59 AM
Find and Replace - delete the remainder of the text in the cell after my Find [email protected] Excel Programming 4 August 4th 07 03:39 AM
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
find and delete duplicate entries in two columns or find and prin. campare 2 columns of numbers-find unique Excel Programming 1 November 24th 04 04:09 PM
find and delete text, find a 10-digit number and put it in a textbox Paul Excel Programming 3 November 16th 04 04:21 PM


All times are GMT +1. The time now is 07:58 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"