+ Reply to Thread
Results 1 to 5 of 5

VBA code to hide filtered columns (simple table 5 rows / 6 columns wide)

  1. #1
    Registered User
    Join Date
    04-27-2013
    Location
    london, england
    MS-Off Ver
    Excel 2003,2010
    Posts
    5

    VBA code to hide filtered columns (simple table 5 rows / 6 columns wide)

    Hi,

    I have a simple table in Excel 2010 (5 rows / 6 columns).
    I would like the user to be able to filter the table.
    After the filter, I would like to hide any columns that only contain (visible) 'N' characters.

    I would like to do this in VBA.

    The file can also be downloaded from:
    https://dl.dropboxusercontent.com/u/...n_columns.xlsm

    Any help much appreciated.
    Thank you
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,165

    Re: VBA code to hide filtered columns (simple table 5 rows / 6 columns wide)

    Hi e and welcome to the forum,

    See if this kind of code helps you learn VBA. Adjust Top, Botton, Left and Right as needed.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    04-27-2013
    Location
    london, england
    MS-Off Ver
    Excel 2003,2010
    Posts
    5

    Re: VBA code to hide filtered columns (simple table 5 rows / 6 columns wide)

    MarvinP, thank you for the code / reply.

    After 2 days of searching and trying different things, I've come to the conclusion that its not possible to do what I want.

    Many controls (command buttons, comboboxes etc) allow you to click on them and gain access to the code window / events underneath so you can add your own code.
    The Filter does not seem to have this property / ability.
    I wanted to click on the filter and then the macro would run without having to do anything else.

    Here I would have to :
    (1) click on the filter and make my adjustments.
    (2) then manually run the macro HideColIfAllN

    I'm trying to avoid manully running step (2) - if you see what I mean.

    Thanks anyway.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: VBA code to hide filtered columns (simple table 5 rows / 6 columns wide)

    Hi e2010,

    You may be able to trick Excel into doing what you want. It seems that a volatile function (such as SubTotal [of AutoFilter data]) on an unrelated sheet would generate the required event. Thanks to brettdj in the 2nd post in the following thread for the concept: http://stackoverflow.com/questions/1...nning-a-filter

    See the file associated with post#4 in the following thread: http://www.excelforum.com/excel-prog...ml#post3883023

    It may or may not point you in the right direction.

    Lewis

  5. #5
    Registered User
    Join Date
    04-27-2013
    Location
    london, england
    MS-Off Ver
    Excel 2003,2010
    Posts
    5

    Re: VBA code to hide filtered columns (simple table 5 rows / 6 columns wide)

    thanks for the replys

+ 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. How to hide specific checkbox-filtered-columns in the entire workbook?
    By chucro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2012, 06:19 AM
  2. [SOLVED] Loop through rows/columns H and K in filtered table and send emails - Help Please Gurus ;)
    By Alina1404 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2012, 03:23 AM
  3. Loop a code using the values of various columns and rows within a table
    By TommyToe in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-17-2012, 06:01 PM
  4. [SOLVED] simple code hide/show rows with cell = empty, set value or any val
    By ivory_kitten in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2006, 09:30 PM
  5. [SOLVED] How to hide columns that are not filtered?
    By MagnuM in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-05-2006, 02:50 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