+ Reply to Thread
Results 1 to 3 of 3

Spreadsheets and hiding/deleting empty columns

  1. #1
    Registered User
    Join Date
    09-08-2008
    Location
    Austin, TX
    Posts
    5

    Spreadsheets and hiding/deleting empty columns

    Hello folks, I have a problem I can't figure out. I'm trying to write a macro that will examine a column and if no data is in the column, hide the column (or delete if "Hide" is impossible) and the column before it.

    Example:

    Column A - Date of Sale
    Column B - Type of Sale
    Column C - Business name
    Column D - Salesperson's name
    Column E - Salesperson's ID number
    Column F - Cold/Warm call made?
    Column G - Signature
    Column H - Contact call?
    Column I - Signature
    Column J - Spoke to Contact?
    Column K - Signature
    .... etc until the last column Y is reached ending with the signature for project X


    The report that my system generates shows EVERYTHING and it's a very long document. Even in landscape, it's three pages across--and Heaven help you if you have to run it for an entire month! It's almost two hundred pages!

    So to cut down on the pages and the searching, I'm trying to create a macro that will hide the signature column if contains no values other than a dash "-". In addition, it hides the column before it.

    So if Column K had zero signatures and only a single dash in each cell, the macro would remove that column and column J.

    Can this be done 'cuz I can't figure it out to save my life.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Spreadsheets and hiding/deleting empty columns

    I would need to use a macro

    The question is how would you trigger it?

    To keep it simple I would clear all cells that contain just a dash

    Then I would look at each column of data and use counta to find the number of non blank cells in my data

    that would allow me to hide the two relevent columns.

    this should be quite easy. [ Famous Last Words ].

    I will need to use an array to store the columns that you want tested and hidden, as you haven't posted your spreadsheet.

    So you may need to modify the array.




    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-31-2015 at 06:29 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    09-08-2008
    Location
    Austin, TX
    Posts
    5

    Re: Spreadsheets and hiding/deleting empty columns

    Gah, my macro wasn't even close! This is perfect! Works like a charm!

    If this forum had a donate button, you'd get the full contents of my savings account! $18 AND 42 cents!

    Seriously, you're a rockstar. Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Hiding empty columns in range
    By jhonneyboy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-03-2014, 06:02 PM
  2. Filtering a selected row, then hiding all columns that are empty
    By dhpham in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2013, 12:44 PM
  3. Deleting Empty Columns from all Worksheets
    By DonaldTerry in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2012, 09:19 AM
  4. Deleting empty rows and columns
    By JMye in forum Excel General
    Replies: 1
    Last Post: 06-20-2008, 01:46 PM
  5. Deleting Empty Columns
    By scott in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2005, 05:06 PM

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