Solved

Excel 2007 Delete Columns when rows below are blank

Posted on 2014-09-30
2
305 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:infosec36
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
Comment Utility
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:infosec36
Comment Utility
Thank you so much for the quick response.  It works perfectly and is exactly what I needed.

Regards,
InfoSec36
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now