+ Reply to Thread
Results 1 to 11 of 11

VBA to hide/unhide column with respect to a cell value

  1. #1
    Forum Contributor
    Join Date
    09-04-2007
    Posts
    127

    Exclamation VBA to hide/unhide column with respect to a cell value

    Hi all,

    I've attached screenshort of a speadsheet :- "PP". The following conditions are to be done:-
    1. When D2=1, Column "F","G" are visible & Column "I","J","L","M" are hidden.
    2. When D2=2, Column "I","J" are visible & Column "F","G","L","M" are hidden.
    3. When D2=3, Column "L","M" are visible & column "F","G","I","J" are hidden.

    Can anyone help me.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    See attached file... I hope it's what you need.

    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    09-04-2007
    Posts
    127

    Exclamation

    hey antonio,

    thanks a lot. Its working. But I have one more small doubt on this same matter. If we have the terget cell (like D2 in Foglio1) in other work shhet. Lets say we want to put the same input value 1/2/3 in sheet no. 2 (Foglio2). Then how can we get the same output at Sheet 1(Foglio1).

    I have attached for your reference.

    please suggest.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    If you want to get input on sheet2 and hide/unhide columns on sheet1 you can do so:
    right click on 'sheet2' label and paste this code:

    Please Login or Register  to view this content.
    Regards,
    Antonio

  5. #5
    Forum Contributor
    Join Date
    09-04-2007
    Posts
    127

    Lightbulb thanks

    hi antonio,

    thanks a lot. Could you please tell me how can I copy one cell's (assume cell A1) value from Sheet 1 to another cell (assume B1 cell) of another sheet (assume Shee2)?

  6. #6
    Forum Contributor
    Join Date
    09-04-2007
    Posts
    127

    not working

    hi antonio,

    This refers to your previous post. this is not working. I have put that code but not working.

    I have attached for your reference.

    Thanks.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    See attached file... I hope it fix your problem.

    If you want to get input on 'input' sheet and hide/unhide columns on sheet 'output' you need to put the 'output' as sheet name on the instruction, for example:
    Please Login or Register  to view this content.
    Regards,
    Antonio
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    09-04-2007
    Posts
    127

    thanks a lot my friends

    Dear antonio,

    Thanks a lot..... its gr8 help. YOU ARE REALLY GENIUS.

    GOD BLESS YOU!!!!!!

    Thanks once again..................

    Cheers!!!!!!

  9. #9
    Forum Contributor
    Join Date
    09-04-2007
    Posts
    127

    Thumbs up

    hi antonio,

    tell me one thing. If i want to hide one column (say 'i') in 1st condition, then the below code is correct?

    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    With range you need to use 'i:i', for example:
    Please Login or Register  to view this content.
    or you can use columns instruction:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  11. #11
    Forum Contributor
    Join Date
    09-04-2007
    Posts
    127

    hey antonio

    thanks again.

    Could you tell me best excel-VBA programming book.

    Cheers !!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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