Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 361
Default Clear Contents Of Cell If Value = 0 or Error

I posted last week on this problem I am trying to solve.


Sub stantiate()
Dim myRange As Range
Set myRange = Range("C10:d1000")
For Each c In myRange
If c.Value = 0 Then
c.Value = ""
End If
Next
End Sub

The code gets hung up at:

If c.Value = 0 Then

the cell value could be #N/A or some other
"errors".

Could this be the reason the code gets hung up ?

If so, is there a way to resolve the problem ?

Thank you in advance.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 25
Default Clear Contents Of Cell If Value = 0 or Error

If I'm understanding you correctly...if the cell value is actually a cell
error, you would like the cell value=0?

"carl" wrote:

I posted last week on this problem I am trying to solve.


Sub stantiate()
Dim myRange As Range
Set myRange = Range("C10:d1000")
For Each c In myRange
If c.Value = 0 Then
c.Value = ""
End If
Next
End Sub

The code gets hung up at:

If c.Value = 0 Then

the cell value could be #N/A or some other
"errors".

Could this be the reason the code gets hung up ?

If so, is there a way to resolve the problem ?

Thank you in advance.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,117
Default Clear Contents Of Cell If Value = 0 or Error

you haven't declared c..........

dim c as Range

blah blah
For Each c In myRange
If c.Value = 0 Then
c.Value = ""
End If
Next

also, "Next" needs to be "Next c"
you might also need to change
c.Value = ""
to
c.clearcontents

hope this helps!
susan


On Jul 9, 10:56 am, carl wrote:
I posted last week on this problem I am trying to solve.

Sub stantiate()
Dim myRange As Range
Set myRange = Range("C10:d1000")
For Each c In myRange
If c.Value = 0 Then
c.Value = ""
End If
Next
End Sub

The code gets hung up at:

If c.Value = 0 Then

the cell value could be #N/A or some other
"errors".

Could this be the reason the code gets hung up ?

If so, is there a way to resolve the problem ?

Thank you in advance.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 361
Default Clear Contents Of Cell If Value = 0 or Error

Thanks for your help.

I need the contents of the cell cleared only if the value = 0.

That said, when I run the macro, some of the cells are #N\A and other error
messages.

I would like the macro to ignore the error messages.

"E-Coder" wrote:

If I'm understanding you correctly...if the cell value is actually a cell
error, you would like the cell value=0?

"carl" wrote:

I posted last week on this problem I am trying to solve.


Sub stantiate()
Dim myRange As Range
Set myRange = Range("C10:d1000")
For Each c In myRange
If c.Value = 0 Then
c.Value = ""
End If
Next
End Sub

The code gets hung up at:

If c.Value = 0 Then

the cell value could be #N/A or some other
"errors".

Could this be the reason the code gets hung up ?

If so, is there a way to resolve the problem ?

Thank you in advance.

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Clear Contents Of Cell If Value = 0 or Error

Does this code do what you want?

Dim C As Range
Dim myRange As Range
Set myRange = Range("C10:d12")
For Each C In myRange
If Not IsError(C.Value) Then
If C.Value = 0 Then C.cl
End If
Next

Rick


"carl" wrote in message
...
Thanks for your help.

I need the contents of the cell cleared only if the value = 0.

That said, when I run the macro, some of the cells are #N\A and other
error
messages.

I would like the macro to ignore the error messages.

"E-Coder" wrote:

If I'm understanding you correctly...if the cell value is actually a cell
error, you would like the cell value=0?

"carl" wrote:

I posted last week on this problem I am trying to solve.


Sub stantiate()
Dim myRange As Range
Set myRange = Range("C10:d1000")
For Each c In myRange
If c.Value = 0 Then
c.Value = ""
End If
Next
End Sub

The code gets hung up at:

If c.Value = 0 Then

the cell value could be #N/A or some other
"errors".

Could this be the reason the code gets hung up ?

If so, is there a way to resolve the problem ?

Thank you in advance.


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
Clear Contents of Adjacent Cell on Conditional Basis DoooWhat Excel Discussion (Misc queries) 8 March 7th 07 02:38 PM
Is there a formula to clear the contents of a specific cell? Bob Smith Excel Worksheet Functions 2 December 9th 06 07:41 PM
How do I clear the contents of one cell from another cell? RonB Excel Worksheet Functions 1 September 26th 05 07:33 PM
vb to clear cell contents RichT New Users to Excel 6 June 27th 05 08:26 AM
Clear cell contents with a button KFC / A&W Boy Excel Worksheet Functions 1 March 7th 05 09:39 AM


All times are GMT +1. The time now is 03:26 PM.

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"