+ Reply to Thread
Results 1 to 8 of 8

VBA Show Certain Columns Hide Others

  1. #1
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    VBA Show Certain Columns Hide Others

    Hello,

    I have this sheet that has columns for certain year months and totals.

    Can VBA be assigned to the shapes designating the years so that when clicking it will only show the months and totals for that particular year and hide the other years?

    For instance the shape 2023 will show columns E-R and hide columns S-EM.

    2024 will show S-AF and hide E-R and hide AG-EM.

    2025 will show AG-AT and hide E-AF and hide AU-EM.

    Also there needs to be VBA to show all columns and VBA to hide columns E-EM.

    Thank you very much for your help.
    Attached Files Attached Files

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA Show Certain Columns Hide Others

    https://wellsr.com/vba/2020/excel/vba-hide-columns/

    Please Login or Register  to view this content.

    https://analysistabs.com/excel-vba/h...worksheet/#bm3

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: VBA Show Certain Columns Hide Others

    Thanks @Logit.

  4. #4
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: VBA Show Certain Columns Hide Others

    I did some work getting the correct columns assigned to each shape:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: VBA Show Certain Columns Hide Others

    1. Assign this macro to all shapes that define years:
    Please Login or Register  to view this content.
    2. To both shapes specifying all columns, assign the macro:
    Please Login or Register  to view this content.
    3. Select all shapes and change their property to "Do not move or resize with cells"
    4. Select whole rows 1:3 and give them the color of your choice.

    Done.

    Artik

  6. #6
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: VBA Show Certain Columns Hide Others

    Thanks for the help guys.

  7. #7
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: VBA Show Certain Columns Hide Others

    A small correction in the ShapeYear_Click procedure.
    Instead of this line:
    Please Login or Register  to view this content.
    insert:
    Please Login or Register  to view this content.
    Artik

  8. #8
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: VBA Show Certain Columns Hide Others

    Thank you @Artik.

+ 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] Show/HIde Columns using VBA
    By pdalal in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-13-2016, 04:03 PM
  2. Show / Hide columns
    By DBenson1968 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2014, 05:27 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. Check Box to Show/Hide Columns
    By rudy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-27-2006, 05:08 PM
  6. how can hide and show columns using macro?
    By Hoshyar in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 PM
  7. [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