Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
delete columns if cells have no data
..Hi
I have a worksheet where rows 1 & 2 and columns A & B are fixed headings. I would like a macro where any columns (C:BH) are deleted if they have no data. All of the cells in the range (C3:BH500) have formulas. I have tried to adapt other similar solutions found here, but to no avail. Any help would be greatly appreciated. Malcolm |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
delete columns if cells have no data
Post your formulas.
If they are formulas that return a string "" then this macro will do the job. Sub test() For Each cell In ActiveSheet.Range("C1:BH500") If cell = "" Then cell.ClearContents End If Next cell End Sub Gord Dibben MS Excel MVP On Tue, 4 Aug 2009 08:26:02 -0700, wizardmalcolm wrote: .Hi I have a worksheet where rows 1 & 2 and columns A & B are fixed headings. I would like a macro where any columns (C:BH) are deleted if they have no data. All of the cells in the range (C3:BH500) have formulas. I have tried to adapt other similar solutions found here, but to no avail. Any help would be greatly appreciated. Malcolm |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
delete columns if cells have no data
Hi Gord,
Thank you for your reply. The formulas collect numbers from a seperate worksheet (called "Quote") if criterias are met. The formula for cell C3 for example is =IF(Quote!$J8=C$2,Quote!$P8,0) C2:BH2 are text headings. If any columns then contain no numbers in cells 3:500, I would like the macro to either hide or delete that blank column. Thanks Malcolm "Gord Dibben" wrote: Post your formulas. If they are formulas that return a string "" then this macro will do the job. Sub test() For Each cell In ActiveSheet.Range("C1:BH500") If cell = "" Then cell.ClearContents End If Next cell End Sub Gord Dibben MS Excel MVP On Tue, 4 Aug 2009 08:26:02 -0700, wizardmalcolm wrote: .Hi I have a worksheet where rows 1 & 2 and columns A & B are fixed headings. I would like a macro where any columns (C:BH) are deleted if they have no data. All of the cells in the range (C3:BH500) have formulas. I have tried to adapt other similar solutions found here, but to no avail. Any help would be greatly appreciated. Malcolm |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete Columns and Color Cells | Excel Discussion (Misc queries) | |||
How to Delete Extra Cells and Columns | Excel Discussion (Misc queries) | |||
Delete rows with empty cells in columns B&C | Excel Discussion (Misc queries) | |||
Formula to delete blank cells across multiple columns? | Excel Worksheet Functions | |||
delete columns and rows-cells equalling zero or any selected value | Excel Worksheet Functions |