+ Reply to Thread
Results 1 to 12 of 12

Show and Hide columns pending on value in validation

  1. #1
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Show and Hide columns pending on value in validation

    Hi,
    I try to make a bookkeeping to log in my yearly expensive by months and days.
    I will create columns 12 mothns with 28-31 days pending on the month.

    The example I show only 3 months and 10 days for each month. There is a validation
    showing the months. Once the of Jan is selected, then only shows the columns for Jan
    and YTD summary column. All other columns will be hidden. The validation list has
    Jan, Feb, Mar, Show past months histor, Show All.

    Please, Thank You.
    Last edited by Rocky2013; 02-05-2015 at 06:47 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Show and Hide columns pending on value in validation

    Please see the Links At the bottom of this page under "Similar Threads", when I see somebody asking for VBA help and supply a .XLSX file as an example instead of .XLSM file, I suspect any attempts for that person trying something on their own does not exist.

  3. #3
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Show and Hide columns pending on value in validation

    Thanks for the reply.

    I provide xlsx file for easy to explain than wording, also to work around the layout what to do.
    I attempt to use data grouping without VBA, also I think maybe if VBA is better, just pick a month
    from validation list, then columns will hide and unhid. I am very bad in VBA, I have difficult to
    start from blank paper but maybe I can modify the code to change the cell range to make it work.
    In the past I use macro recording for simple codes but not this one.

    I copied all your codes to sheet1, then run each marco one by one. Each time, I pick the value in
    validation, I do not see anything happened. I must misuse your codes and did something wrong.

    Please excuse me for my unexperience in VBA, it will be a long way for me to learn to be a pro.

    Thanks
    Last edited by Rocky2013; 02-01-2015 at 10:21 AM.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Show and Hide columns pending on value in validation

    I referred to the bottom of this page under "Similar Thread", not the bottom of my post.

    Copying my Selections codes is great and you should save them in your "personal macro workbook" for future references. However , if you scroll down to the bottom of this page, you will see a topic titled, "Similar Threads".

    Check out those threads and see if you can get any ideas.

    I just want you to show something you have tried.

  5. #5
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Show and Hide columns pending on value in validation

    Hello
    Greetings for the day!!

    I don't have much knowledge about vba but I have tried to make out a simple way to do this
    Please Check out the attached worksheet

    Select any month and press the Go button....

    Tell me if it works right….

    Hope it helps
    Do ask for any other query you may have…

    If you are satisfied then mark then PLEASE mark this thread as “SOLVED” (by going to thread tools at the top and clicking on “mark this thread as solved”) and you can just click on ADD REPUTATION below my post to say thanks...

    Regards
    Sourabh Gupta

  6. #6
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Show and Hide columns pending on value in validation

    Oops forgot to attach the sheet...
    here's it...

  7. #7
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Show and Hide columns pending on value in validation

    Hello,

    Daveexel,
    OOps, I went to the wrong place to get the information. I checked the similar post, do not find any solution similar to this. Actually there is one
    similar post was belonged to me.

    sourabhg98,
    It works for this example. I create this simple one trying not to complicate the work load for the helpers.
    When I play around to move the functions in row 30 to row 7; add more columns to get actual no. of days , it stop working.
    Also I fell may even have problem later when I add more columns for the rest of the months and days. I can try to understand
    your codes modify to make it work, I feel I will struggle after initally playing around with codes. If this simple for you, can you
    make it work for the rest of the months. I can pre-add columns for April to Dec to cut down your time.

    I am OK to click a "Go" button to update; but is that possible without a button, the update will be pending on the selected value in validation
    list.

  8. #8
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Show and Hide columns pending on value in validation

    Hello
    I have made tables for all the months for you.

    Tell me if it works right….

    Hope it helps
    Do ask for any other query you may have…

    If you are satisfied then mark then PLEASE mark this thread as “SOLVED” (by going to thread tools at the top and clicking on “mark this thread as solved”) and you can just click on ADD REPUTATION below my post to say thanks...
    Regards
    Sourabh Gupta

  9. #9
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Show and Hide columns pending on value in validation

    Hello,

    New excel file upload, the previous one has issue that I forget to save I edited. I thought I did.

    There is one correction I like to make is to move the contents in H30:OE30 to H6:OE30. When
    I did, VBA stops working. Because I will have lot of rows of data. Please explain what to change
    in codes in case I want to move to different place.

    Thanks
    Last edited by Rocky2013; 02-04-2015 at 03:15 PM.

  10. #10
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Show and Hide columns pending on value in validation

    I looked at the code, I could not figure out.

    Any sugguestion please?
    Last edited by Rocky2013; 02-05-2015 at 06:34 PM.

  11. #11
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Show and Hide columns pending on value in validation

    Just cut paste the formula to sixth row
    Go to Sub Hide columns and make following changes
    For Each cell In Range("H30:OF30")

    change it to--
    For Each cell In Range("H6:OF6")
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  12. #12
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Show and Hide columns pending on value in validation

    Thanks. It works now.

    I thought I tried that to move the row then changed the range; but it did not work. That must be something wrong what I did. I have a long way to know VBA.

+ 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. Show / Hide columns
    By DBenson1968 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2014, 05:27 PM
  2. [SOLVED] Create a validation list in E2 pending on D2
    By Rocky2013 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-26-2013, 08:26 PM
  3. Excel 2008 : Hide/show columns
    By Didieeer in forum Excel General
    Replies: 1
    Last Post: 02-02-2012, 07:36 AM
  4. Hide Show columns
    By Glio in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2007, 06:10 AM
  5. [SOLVED] Show/Hide Columns
    By StephanieH in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-24-2005, 10:05 AM

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