+ Reply to Thread
Results 1 to 7 of 7

Delete entire column if all cells in a certain range are empty

  1. #1
    Registered User
    Join Date
    10-26-2011
    Location
    York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Delete entire column if all cells in a certain range are empty

    I'm not experienced with macros but I'm trying to automate a spreadsheet formatting process to save me a lot of time. One of the functions I need to perform is to delete columns where all cells within a certain range are empty. So, in columns C to FZ, if cells 3 to 1000 are all empty, delete the entire column.

    Can anyone help me with this?

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Delete entire column if all cells in a certain range are empty

    Hi,

    Try this:

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Delete entire column if all cells in a certain range are empty

    Hi,

    Create a helper row 1 and use =IF(SUM(C4:C1001)=0,"delete","keep")

    Now use a macro along the lines of
    Please Login or Register  to view this content.
    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Delete entire column if all cells in a certain range are empty

    another option:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-26-2011
    Location
    York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Delete entire column if all cells in a certain range are empty

    Thanks Dom, that works nicely

  6. #6
    Registered User
    Join Date
    10-26-2011
    Location
    York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Delete entire column if all cells in a certain range are empty

    Nilem - even better, thanks

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Delete entire column if all cells in a certain range are empty

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    Create a helper row 1 and use =IF(SUM(C4:C1001)=0,"delete","keep")

    Now use a macro along the lines of
    Please Login or Register  to view this content.
    Regards
    That formula should of course be put in C1 and copied across to FZ1 and the Range in the macro refer to C1:FZ1 and not my test range of G1:L1

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1