+ Reply to Thread
Results 1 to 11 of 11

Looking for a Macro to Unhide Columns based on a User's Input

  1. #1
    Registered User
    Join Date
    04-02-2014
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Smile Looking for a Macro to Unhide Columns based on a User's Input

    Hi. I'd like for my spreadsheet to open with only Column A visible; I'd like all other collumns to stay hidden.

    I want to create a marco to unhide column(s) based on the value of an individual cell.

    For example:
    if I enter the number 5 into cell A1, I would like Columns B:F to unhide.
    if I enter the number 2 into cell A1, I would like Columns B:C to unhide. Is this possible?


    Thanks!!

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Maybe put:
    Please Login or Register  to view this content.
    in the worksheet object code module.

  3. #3
    Registered User
    Join Date
    12-10-2013
    Location
    Mississippi, United States
    MS-Off Ver
    2010
    Posts
    70

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Paste this is the worksheet part of VBA

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-02-2014
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Thank you ragulduy! The code worked!!!

    Unfortunately, I was a little short-sighed in my question. Any suggestions as to what I should do if I wanted to keep Columns A:C visible and assigned cell C1 to unhide columns D:XFD based on a User's Input?

    Apologies for not being specific enough in my original posting

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-02-2014
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Thank you ragulduy, works like a charm!! I really appreciate the help!!

    Thank you also to aworfolk. Your solution didn't quite work as I needed, but I appreciate the response and thank you for your time!!!!

  7. #7
    Registered User
    Join Date
    04-02-2014
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Afterthought:

    I'd like to make "duplicate sheets" within my woorkbook, with 1 change: I'd like Sheet2 to run off the same target cell used in Sheet1 (C1)

    I can't quite figure out how to add sheet names into the code posted above. Is this an easy fix? (i hope)

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-02-2014
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Thank you for the response. I think I may be applying the code incorrectly as it is not working.

    I've added the code to Sheet1 and received a "Compile error: Ambiguous name detected: worksheet_change"

    I then inserted the code into Sheet2, but nothing happens. Have I selected from the two dropdown boxes correctly - "Worksheet" and "Change"?

  10. #10
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Hi - you can only have one worksheet_change() routine in each sheet module. It needs to go in sheet1 because this is the one that you will be changing the number on.

    You need to replace the current worksheet_change macro or combine them if they have different purposes.

  11. #11
    Registered User
    Join Date
    04-02-2014
    Location
    Connecticut, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Looking for a Macro to Unhide Columns based on a User's Input

    Oh, that was really dumb of me Thank you!! It works perfectly!

+ 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] Averaging a user input defined range based on values in columns
    By smit.etha in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-14-2014, 02:21 AM
  2. [SOLVED] Adding X Columns for user input based on value of one cell
    By reluctantresearch in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-25-2013, 01:50 PM
  3. [SOLVED]Hide Rows and Columns Based on User Input
    By thesteve in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2013, 01:32 PM
  4. user defined macro to replace certain characters in a string based on user input
    By whatappears in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2012, 06:25 PM
  5. Automatic Formula Input Based on User Input Using a Macro
    By Drayloc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2012, 12:10 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