?
Solved

Excel 2007 Delete Columns when rows below are blank

Posted on 2014-09-30
2
Medium Priority
?
329 Views
Last Modified: 2014-09-30
Hello Experts,

I need to be able to cut down on the amount of blank columns I have in a spreadsheet.  Each column has a title and below the title there may be some cells which are populated and some which are not.  I want to delete any column which has only blank cells beneath the title.

I have attached an example of the spreadsheet.  The first five rows will always blank.

Regards,
Infosec36
Remove-Blank-Columns.xls
0
Comment
Question by:Sonia Bowditch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 2000 total points
ID: 40352003
Sub DeleteColumns()
intcol = 1
Do While Cells(6, intcol) = "OVERRIDE"
    If Application.WorksheetFunction.CountA(Columns(intcol)) = 1 Then
        Columns(intcol).Delete
    Else
        intcol = intcol + 1
    End If
Loop
End Sub

Open in new window

0
 

Author Closing Comment

by:Sonia Bowditch
ID: 40352008
Thank you so much for the quick response.  It works perfectly and is exactly what I needed.

Regards,
InfoSec36
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question