+ Reply to Thread
Results 1 to 16 of 16

Hide columns automatically based on year and month imputs

  1. #1
    Registered User
    Join Date
    07-30-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    8

    Question Hide columns automatically based on year and month imputs

    Hello everyone! and thank you for your time.

    I work as a financial analyst and I have a VBA question. I would appreciate if you can help me.

    My goal is for excel to hide automatically certain columns depending on the imputs on two cells, which indicate the YEAR and MONTH desired. I want the DAY to always be the last possible day of the month.

    I have google this, and the best solution I have found is:

    Please Login or Register  to view this content.
    This code works great, but I have two issues. The first one is that it feeds the code with the date in the cell O3 rather than getting the year and month from P5 & P6. To solve this, I have used this formula on the cell O3 =DATE(P5;P6+1;0). The problem I am having now is that when I change either the year or month the colums wont hide until I click on O3 and press enter. I guess the code above requires you to interact with that cell specifically. Changing the value doesn't trigger the code.

    The second issue, a minor one, is that I want the month and year imput to be on a different sheet. As this cells are going to be linked to a bunch of sheets.


    Can you guys please help me with this? I tried googling it but can't find a solution.

    Thank you in advance.


    EDIT: I have posted this on another website. Didnt know it was against the rules. The reason I am posting here now is because I couldn't upload a file on the other forum. Thank you.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by ToroRubio; 07-30-2020 at 07:03 AM.

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Hide columns automatically based on year and month imputs

    Try below code
    Please Login or Register  to view this content.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Registered User
    Join Date
    07-30-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    8

    Re: Hide columns automatically based on year and month imputs

    Works wonders, thank you so much .

    The only thing now, can the month and year imputs be on a different sheet?

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Hide columns automatically based on year and month imputs

    you can but need to change the code little bit.

  5. #5
    Registered User
    Join Date
    07-30-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    8

    Re: Hide columns automatically based on year and month imputs

    Hello Samba,

    Can you please help me with that? I'm not very educated on VBA.

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Hide columns automatically based on year and month imputs

    Attach the file

  7. #7
    Registered User
    Join Date
    07-30-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    8

    Smile Re: Hide columns automatically based on year and month imputs

    You have no idea how much I appreciate your help.

    I attached the file.
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Hide columns automatically based on year and month imputs

    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.

    (Note: this requirement is not optional. As you are new, I will do it for you today: https://www.mrexcel.com/board/thread...mputs.1141244/.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Registered User
    Join Date
    07-30-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    8

    Re: Hide columns automatically based on year and month imputs

    Hello Ali.

    Understood. I cross-posted because of the ability to upload spreedsheets in this forum.

    Thank you.

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Hide columns automatically based on year and month imputs

    You may understand, but you are required to advise us of the crossposting. Please provide the URL to the other posting. Please read the forum rules you agreed to when you joined this forum.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  11. #11
    Registered User
    Join Date
    07-30-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    8

    Re: Hide columns automatically based on year and month imputs

    - You are required to advise us of the crossposting.
    I edited the post to do exactly that.

    - Please provide the URL to the other posting.
    Ali did that for me.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Hide columns automatically based on year and month imputs

    I provided the link because you are new here. Next time you will be required to do it yourself.

    Didnt know it was against the rules.
    You should have, though. When you joined, you agreed to abide by them, so you should have read them. Here's a link for your convenience so that you can read them now: https://www.excelforum.com/forum-rul...rum-rules.html
    Last edited by AliGW; 07-30-2020 at 09:43 AM.

  13. #13
    Registered User
    Join Date
    07-30-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    8

    Re: Hide columns automatically based on year and month imputs

    Honestly, I dont understand why you guys are being so rude with me.

    I made a mistake and I apologize when I realiced I did. I edited the post before any admin said anything. I have been all the time receptive.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Hide columns automatically based on year and month imputs

    Nobody is being rude to you.

  15. #15
    Registered User
    Join Date
    07-30-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    8

    Re: Hide columns automatically based on year and month imputs

    How can I delete my account?

    I have sent you guys a couple of messages and still no reply.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Hide columns automatically based on year and month imputs

    I have not received any messages from you, sorry, otherwise I would have replied. How and when did you send them?

    You cannot delete your account, or close it, but you can choose not to use it, if you wish.

+ 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] Automatically hide and unhide rows based on selected month
    By dondonordas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2018, 02:07 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. Hide Columns automatically based on date
    By ravisidhu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2015, 01:15 AM
  4. Hide/show columns based on the year in the header of the column
    By lukelucky in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-19-2015, 04:03 AM
  5. Hide Columns automatically based on year month(YYYY-mm)
    By Jeevhoney in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2014, 12:53 AM
  6. Replies: 2
    Last Post: 12-01-2012, 03:06 PM
  7. Hide Columns automatically based on date
    By chrisjc19 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-06-2011, 03:32 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