+ Reply to Thread
Results 1 to 9 of 9

Need code to hide columns when button pressed

  1. #1
    Registered User
    Join Date
    06-24-2021
    Location
    India
    MS-Off Ver
    365
    Posts
    7

    Red face Need code to hide columns when button pressed

    Hi, Can you please help me with this code?

    Hide specified columns:
    1. Click a button in excel
    2. Message prompt will pop up “Which columns do you want to hide?” with a text box to type in the answer
    3. User types in a range of consecutive columns (ex: A:C). Clicks OK.
    4. The specified columns are hidden and a message box pops up to say “Done!”
    5. If user clicks the button again and enters the same range or subset of the range (which is already hidden), another message box will pop up to say 6. “It’s already hidden!” However, if it is an overlapping range (ex: C:E, where col C is already hidden), only the unhidden part of the range will be hidden (ex: D:E).

    Thanks in advance.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Excel VBA code

    Attach this code to a button...
    Please Login or Register  to view this content.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Excel VBA code

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    Because it is your first post I will provide the link: https://www.mrexcel.com/board/thread...-code.1174682/

    However, please take the time to review our rules before you continue posting.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    06-24-2021
    Location
    India
    MS-Off Ver
    365
    Posts
    7

    Re: Excel VBA code

    Thank you so much.
    Last edited by payalbansal01; 06-25-2021 at 03:22 AM.

  5. #5
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Excel VBA code

    It works for me.

    How about telling us what you did with the code, how you ran the macro, what you put as input to the prompt and why you think it's not working?

    Saying it is 'not working', and asking someone who helped you to 'check again' is not a good response IMO.

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Excel VBA code

    It seems I missed your reply, payalbansal01... care to repost it?

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Need code to hide columns when button pressed

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #1 requires good titles. "Excel VBA code" is not a good title. I have updated it for you this time because you are a new member. --6StringJazzer

  8. #8
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Need code to hide columns when button pressed

    About time the rules were updated.

    "It does not work" as a response, should be against the rules, especially when the code provided actually DOES work.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Need code to hide columns when button pressed

    Quote Originally Posted by Croweater View Post
    "It does not work" as a response, should be against the rules, especially when the code provided actually DOES work.
    Moderator's note: Just in case anyone is confused, this comment refers to post #4, which has been updated and no longer says the solution doesn't work.

    BTW here is my standard response when someone says something doesn't work:



    Please explain what "doesn't work" means.
    • Does the code run?
    • Does it run but do nothing?
    • Does it produce error messages? If so, what do the messages say?
    • Does it produce unexpected/wrong results? If so, how do the results differ from what you expect?
    • Does it hang?

+ 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. Replies: 9
    Last Post: 10-07-2019, 07:32 AM
  2. vba code to recognise what button is pressed in internet explorer
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2017, 07:07 AM
  3. Toggle Button on Workbook Open - value is True but button not pressed?
    By excelnat in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-03-2014, 11:23 AM
  4. vba code for ESC button , when pressed excel file goes to sheet1
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-08-2013, 05:21 PM
  5. Code to see which button was pressed
    By whatsmyname in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-13-2013, 08:18 PM
  6. Replies: 3
    Last Post: 12-27-2012, 12:26 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