+ Reply to Thread
Results 1 to 10 of 10

Vba code to hide specific cells

  1. #1
    Registered User
    Join Date
    03-08-2024
    Location
    Mexico
    MS-Off Ver
    Office 365
    Posts
    8

    Vba code to hide specific cells

    Hi everyone

    I´m constructing the file attached in order to have my workshop processes simplified. I´ve applied VBA coding to the cells where Main Categories (deep blue) and Subcategories (light blue) are placed (I have inserted button and then applied macros to them) so that the desired result is that they hide the cells with the range specified.

    However I´m having trouble when clicking on Main Categories buttons (the four big-blue ones) because all cells of the category deploy, when in reality what shoud be is that only the Subcategories buttons are deployed (like in the attached image), so then its the user the one that decides which Sucategory to deploy.

    Is there a way to change the code I applied in order to get this desired effect?
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    935

    Re: Vba code to hide specific cells

    Just a hint, it might work. Try splitting row ranges and skip subcategory rows; here's the example for the main category POWERTRAIN:
    Please Login or Register  to view this content.
    Last edited by rollis13; 03-08-2024 at 06:15 PM.
    Difficult is not to know but to share what you know (Han Fei Tzu reworked)

  3. #3
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    935

    Re: Vba code to hide specific cells

    Duplicated post deleted.
    Last edited by rollis13; 03-08-2024 at 06:20 PM.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Vba code to hide specific cells

    Or
    When all the rows are visible (not hidden), use this as a toggle.
    Please Login or Register  to view this content.
    Change the other macros accordingly.
    The inherent weakness of the liberal society: a too rosy view of humanity.

  5. #5
    Registered User
    Join Date
    03-08-2024
    Location
    Mexico
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Vba code to hide specific cells

    Hi

    Your solution was worked partially, the thing now is that when not toggled, the Main category button already deploy the Sub categories buttons, when the desire is to show the Sub categories only when toggling the Main Categories. Here´s the "ideal sequence":

    1. When not toggled, the only thing appearing in screen are the 4 Main Categories buttons (Body, Chassis, Electrical & Powertrain).

    2 When toggling a certain Main Category button, the cells to appear have to be only the Sub Categories buttons. (Taking as an example the Electrical, the only cells that must appear when toggling are rows 134,150,163).

    Your solution has already helped me a lot! Just wondering what change must be applied to you code in order to have the desired sequence...

  6. #6
    Registered User
    Join Date
    03-08-2024
    Location
    Mexico
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Vba code to hide specific cells

    Quote Originally Posted by rollis13 View Post
    Just a hint, it might work. Try splitting row ranges and skip subcategory rows; here's the example for the main category POWERTRAIN:
    Please Login or Register  to view this content.
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Hi

    Your solution was worked partially, the thing now is that when not toggled, the Main category button already deploy the Sub categories buttons, when the desire is to show the Sub categories only when toggling the Main Categories. Here´s the "ideal sequence":

    1. When not toggled, the only thing appearing in screen are the 4 Main Categories buttons (Body, Chassis, Electrical & Powertrain).

    2 When toggling a certain Main Category button, the cells to appear have to be only the Sub Categories buttons. (Taking as an example the Electrical, the only cells that must appear when toggling are rows 134,150,163).

    Your solution has already helped me a lot! Just wondering what change must be applied to you code in order to have the desired sequence...

  7. #7
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    935

    Re: Vba code to hide specific cells

    Try with these other tweaks (example for POWERTRAIN):
    Please Login or Register  to view this content.
    and these others respectively modified as follows:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-08-2024
    Location
    Mexico
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Vba code to hide specific cells

    Quote Originally Posted by rollis13 View Post
    Try with these other tweaks (example for POWERTRAIN):
    Please Login or Register  to view this content.
    and these others respectively modified as follows:
    Please Login or Register  to view this content.
    --------------------------------------------------------------------------------------------------------------------------------------------

    Thanks a lot! I´ve applied to all respective cells and now the whole file is toggling as desired. Much appreciated.

  9. #9
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    935

    Re: Vba code to hide specific cells

    Thanks for the positive feedback, glad we were able to help.
    By the way, you probably need to mark this thread as [Solved].

  10. #10
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,521

    Re: Vba code to hide specific cells

    I propose another solution that does not refer to specific row numbers. It analyzes the colors of the shapes (and cells).
    To use it, you need to "clean up" a bit first by running the ArrangeShapes procedure once. The same macro is assigned to all shapes in the 15:200 row range. You will be able to discard all the modules you have had in the project so far.
    If the category ranges change in the future, just run the ArrangeShapes procedure once again.

    Artik
    Attached Files Attached Files

+ 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] Hide/Unhide Scroll Bars Code for Specific Sheets
    By crazyforexcel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2019, 09:28 AM
  2. Help with ToggleButton VBA code to hide/show specific worksheets
    By aprilnparker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-14-2018, 03:04 PM
  3. VBA code for Checkbox to hide and unhide rows by a specific name
    By NichlasO in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-19-2017, 12:38 PM
  4. [SOLVED] Need code to hide specific rows based on different cell value
    By majzeln in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2016, 02:02 PM
  5. code to hide specific rows
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-23-2016, 11:05 AM
  6. Would like to hide specific text inside macro vba code
    By keisen in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-24-2015, 07:08 PM
  7. [SOLVED] Specific macro or VBA code to hide and unhide rows
    By louvaek in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-17-2014, 07:36 AM

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