Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default code to clearcontents of "0" values in cells

This should be simple, but I'm just not getting it. There are only two
ranges I care about Range("J:J") and Range("K:K"). There are many
numeric values in the cells in these columns, but I just want to run a
macro to delete all the "0" values. I've muddled in this, and the
closest I could get it tested the value with an if statement and then,
when it found the range true to have a "0" within the column, it
cleared the contents of the whole column.

Please help! I just need to delete the cells that have zeros in them
so I can run average totals at the bottom of the columns. Obviously, I
don't want to average in the zeros!

Thanks,
LeeCB



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
Tod Tod is offline
external usenet poster
 
Posts: 13
Default code to clearcontents of "0" values in cells

You could cycle the range like this:

For i = 0 to 1
if i = 0 then
Set SearchRange = ActiveSheet.Range("J1:J" &
ActiveSheet.Range("J65536").End(xlup).Row)
else
Set SearchRange = ActiveSheet.Range("K1:K" &
ActiveSheet.Range("K65536").End(xlup).Row)
End If
For Each Cell in SearchRange
If Cell.Value = 0 then Cell.ClearContents
Next Cell
Next i

tod
-----Original Message-----
This should be simple, but I'm just not getting it.

There are only two
ranges I care about Range("J:J") and Range("K:K"). There

are many
numeric values in the cells in these columns, but I just

want to run a
macro to delete all the "0" values. I've muddled in

this, and the
closest I could get it tested the value with an if

statement and then,
when it found the range true to have a "0" within the

column, it
cleared the contents of the whole column.

Please help! I just need to delete the cells that have

zeros in them
so I can run average totals at the bottom of the

columns. Obviously, I
don't want to average in the zeros!

Thanks,
LeeCB



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

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
Sheets("Sheet1").Cells.ClearContents Seeker Excel Discussion (Misc queries) 2 October 1st 09 12:00 PM
"Resizing cells" code doesn't work with merged cells Gina Excel Discussion (Misc queries) 2 June 30th 08 01:37 PM
VLookup returning the sum of multiple values from one "code" Matt Excel Worksheet Functions 4 April 28th 08 01:51 PM
"ClearContents" command halts code Dave O Excel Discussion (Misc queries) 3 January 10th 08 03:39 PM
Changing "returned" values from "0" to "blank" LATATC Excel Worksheet Functions 2 October 20th 05 04:41 PM


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