+ Reply to Thread
Results 1 to 6 of 6

VBA to hide columns if criteria is met

  1. #1
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    VBA to hide columns if criteria is met

    Hi all,

    I need a macro that hides all 'unnecessary' columns on command. The row highlighted in green represents the condition that needs to be met, which is =0. So every column that does not have a "door" should be hidden when running the macro (keystroke). Though the 'same' columns (same cluster name) on the right need to be hidden as well...
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: VBA to hide columns if criteria is met

    Perhaps something like
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA to hide columns if criteria is met

    Try:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: VBA to hide columns if criteria is met

    Or try:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: VBA to hide columns if criteria is met

    Perhaps something like
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    Re: VBA to hide columns if criteria is met

    Quote Originally Posted by PaulM100 View Post
    Or try:

    Please Login or Register  to view this content.
    I like that solution, but it doesn't 100% work. The second range ("AE12:BG12") returns 0 sometimes even though there is a door in range ("A2:AD2")... It should only hide the ones without a door

+ 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. [SOLVED] VBA to hide columns based on criteria from 2 cells
    By Paul103 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-04-2016, 12:33 PM
  2. [SOLVED] Macro to Hide Columns in All Sheets based on criteria in Sheet1
    By toci in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-30-2016, 08:38 PM
  3. Hide pivot table columns based on date criteria
    By boontz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-16-2014, 09:56 AM
  4. Code to show/hide columns based on fixed criteria
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2013, 03:39 AM
  5. Excel VBA Hide Duplicate Cell Contents If Two Columns Match Criteria
    By nnewburger in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2013, 01:08 PM
  6. hide rows -- criteria from multiple columns
    By nityesha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-19-2012, 07:05 AM
  7. Hide Columns based on criteria
    By gugg7378 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2011, 03:38 PM

Tags for this Thread

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