Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Benj
 
Posts: n/a
Default how get rid of cells with unused formulas

Hi all thanx in advance
I created a macro to create a new sheet and clone cells from an older sheet
like this
='Sheet1'!B1
then the macro does autofill until row 2000 the reason of doing that is
because sheet1 for example is designed to hold info until that no. of cells
and I want to sort only those columns copied to that sheet, but the problem
is when doing sort with autofilter on, all the empty cells which contains a
value but is not used because on the older sheet this cell is empty (but on
this sheet it shows a zero 0) goes to the top,

My question is how do I delete all the unused cells with the formulas?

Please respond as quickly as possible Thanx!

please respond as quicly sa possible Thanx

  #2   Report Post  
Dave O
 
Posts: n/a
Default

The following code will clear the content of a cell that contains a
formula and whose result is zero. MAKE A BACKUP COPY of your data
before you use this, so you can be sure it does what you want it to do!

Sub Scrub()
Dim nCell As Variant

For Each nCell In ActiveSheet.UsedRange
If nCell.Value < "" And Mid(nCell.Formula, 1, 1) = "=" And _
nCell.Value = 0 Then nCell.ClearContents
Next nCell

End Sub

  #3   Report Post  
David McRitchie
 
Posts: n/a
Default

Dave's solution is removing the formulas with zero values as if you
would never use those formulas again regardless of changes made to
the cells that they had been dependent on, so I think it is an unacceptable solution.
You could do your magic on a copy of the worksheet.

You can change your settings in Tools, options, view, uncheck zero values
which is not clear but it will apply only to the one worksheet. In any case
it would apply to all cells on the worksheet and regardless of whether they
are formulas or number constants.

To be selective you could use conditional formatting and white out
the font. You can still see the zeros in the display if you select all cells;
otherwise you won't see them on a white or automatic (white) background.
They will not print; however, they will print if you have turned on the
Print B&W under File, Page Setup, Sheet. I think C.F. is your safest
solution as you can pick which columns and/or cells are to be affected.
If you have other C.F. then you are, of course, affected by the 3 C.F.
formulas per cell and the their order
Select column D, format, conditional formatting, cell value is equal to 0
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dave O" wrote in message oups.com...
The following code will clear the content of a cell that contains a
formula and whose result is zero. MAKE A BACKUP COPY of your data
before you use this, so you can be sure it does what you want it to do!

Sub Scrub()
Dim nCell As Variant

For Each nCell In ActiveSheet.UsedRange
If nCell.Value < "" And Mid(nCell.Formula, 1, 1) = "=" And _
nCell.Value = 0 Then nCell.ClearContents
Next nCell

End Sub



  #4   Report Post  
David McRitchie
 
Posts: n/a
Default

Actually a much older solution is better for suppressing zero values
selectively -- format with a custom format so that the third parameter
is empty which is a zero value. This allows you to be selective.
Format, cells, number
#,###.00;-#,###.00;;@
the fomat of custom formatting is
positive numbers; negative numbers; zero; text
you can override positive, negative but those are the defaults.

see the topic "Create a custom number format" in your Excel Help.

related: http://www.mvps.org/dmcritchie/excel/formula.htm
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm


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
Can cells containing linked formulas be identified? EA Excel Discussion (Misc queries) 1 July 7th 05 02:37 AM
formulas and cells Aamir Excel Worksheet Functions 2 July 7th 05 01:27 AM
how do i add cells in checkbook register template with formulas? nlc Excel Worksheet Functions 0 June 28th 05 04:57 AM
Min Formulas in #VALUE! Cells Tip Rabbit Rabbit Excel Worksheet Functions 1 March 24th 05 05:47 PM
How do you show formulas in certain cells only (not the whole she. andy Excel Worksheet Functions 2 February 16th 05 08:05 PM


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