Solved

Excel 2007 Delete Columns when rows below are blank

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

Accepted Solution

by:
Phillip Burton earned 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

839 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