MrExcel Publishing
Your One Stop for Excel Tips & Solutions

How do I delete subtotals that are 0.


Posted by adam k on March 28, 2001 3:17 PM

I have a block of data and I subtotal by the field name and I subtotal the field amount. I want to add the logic that:

if subtotalled amount equals 0 then
delete all the records that aggregate to 0
if not then do nothing


basically if the level 2 number is 0, I want to delete all the records in level 3 view the aggregate to that number 0.

I think it pretty straight forward but I just dont know how I would go about doing this

Thanks,

adam


Posted by Jacob Hilderbrand on March 28, 2001 7:07 PM

Try this


sub test()
range([address of data that might be 0, i.e. "A10"]).select
if activecell.value=0
then
range([range of data that you want to delete, i.e. "A1:A9"]).select
selection.clearcontents
end if
end sub

Hope this helps

Jacob

Posted by adam k on March 29, 2001 8:24 AM

I know I could do this. I am trying to find a way to dynamically know what those ranges are ??