Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default 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
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
Delete Columns and Color Cells iperlovsky Excel Discussion (Misc queries) 2 July 1st 08 10:29 PM
How to Delete Extra Cells and Columns Notdony Excel Discussion (Misc queries) 2 June 18th 08 09:27 PM
Delete rows with empty cells in columns B&C Richard Excel Discussion (Misc queries) 3 March 18th 06 12:15 AM
Formula to delete blank cells across multiple columns? SamFunMail Excel Worksheet Functions 2 September 1st 05 07:05 AM
delete columns and rows-cells equalling zero or any selected value Scottie Excel Worksheet Functions 2 May 9th 05 08:47 PM


All times are GMT +1. The time now is 09:06 AM.

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"