+ Reply to Thread
Results 1 to 4 of 4

Hide columns based on cell value

  1. #1
    Registered User
    Join Date
    11-25-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2010
    Posts
    6

    Hide columns based on cell value

    Hi experts,

    So I have the following code, which, ideally, should hide columns (range I1:ABJ1) if their value is lower than what is specified in cell G15.
    However, when I try to run it, it will not hide any columns at all. Can any of you guys spot why that might be? And do you have an idea of how I can fix it?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Hide columns based on cell value

    This line:

    Please Login or Register  to view this content.
    When Target has not been passed or set. Try putting this:

    Please Login or Register  to view this content.
    Before your macro code and then try compiling if from the Debug menu. You'll get errors that you can correct. For now I've had a go at adapting your macro:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Registered User
    Join Date
    11-25-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2010
    Posts
    6

    Re: Hide columns based on cell value

    Thanks WBD!

    The code you provided works like an absolute charm - much appreciated!
    Is it because I'm using a "standard"-module for this particular coding that the
    Please Login or Register  to view this content.
    part didn't work? Because I'm using it on a Worksheet_change module where it works fine :o

    Thank you so much for your help.

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Hide columns based on cell value

    The Worksheet_Change macro is automatically passed the Target variable so it's already defined as the range that has changed. Your code didn't have Target passed or defined.

    WBD

+ 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. Un-hide Columns based on a cell value
    By Stealth2017 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-11-2018, 05:08 AM
  2. [SOLVED] Automatically Hide or not Hide columns, based on cell value (to the left)
    By sherylt13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-04-2018, 07:47 PM
  3. [SOLVED] VBA to hide columns based on a cell value
    By Keibri in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2018, 12:35 PM
  4. Hide Rows/Hide Columns Based on Value in Cell
    By brickwall823 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2015, 02:42 PM
  5. Hide columns based on cell value
    By jwillis07 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-25-2014, 04:59 AM
  6. Hide columns based on value in other cell
    By Johnmus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2011, 04:21 PM
  7. [SOLVED] Hide columns based on cell value
    By [email protected] in forum Excel General
    Replies: 1
    Last Post: 06-23-2005, 01:05 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