+ Reply to Thread
Results 1 to 2 of 2

VBA sub to hide columns according to selections in a dropdwn menu

  1. #1
    Registered User
    Join Date
    02-11-2019
    Location
    Australia
    MS-Off Ver
    10
    Posts
    1

    VBA sub to hide columns according to selections in a dropdwn menu

    Hi I'm looking to use VBA to hide columns based on the values inputted into a series of dropdown menus.
    Each menu asks "Yes" or "No" to whether to include a characteristic which maps to a specific column. The dropdowns are located on the REPORT SET UP worksheet whereas the columns to be displayed or hidden are on the INCOME STATEMENT worksheet.

    I'm trying to get this code to work:

    1 Private Sub Worksheet_Change(ByVal Target As Range)
    2
    3 If Target.Column = 2 And Target.Row = 4 Then
    4 If Target.Value = "No" Then
    5 Application.Worksheets("INCOME STATEMENT").Columns("C:O").Select
    6 Application.Selection.EntireColumn.Hidden = True
    7 ElseIf Target.Value = "Yes" Then
    8 Application.Columns("C:O").Select
    9 Application.Selection.EntireColumn.Hidden = False
    10 End If
    11 End If

    12 End Sub

    This is tripping up on the 5th line currently. Any help would be greatly appreciated.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,493

    Re: VBA sub to hide columns according to selections in a dropdwn menu

    Untested, but maybe this:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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] Using Drop-Down Menu to Hide Columns
    By janklow in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-29-2018, 03:04 PM
  2. [SOLVED] Hide Columns that do not = drop down menu selection
    By Invicta084 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-14-2015, 09:47 AM
  3. Hide Columns Dropdown Menu
    By Viktor86HUN in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 11-25-2013, 07:43 AM
  4. hide month columns using pull down menu
    By deepcdiver in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2010, 08:30 PM
  5. drop down menu to select and hide certain rows and columns
    By ROM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2010, 09:39 AM
  6. [SOLVED] Multiple selections in a drop down menu
    By brmhl in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-02-2005, 12:06 PM
  7. Using the menu selections
    By Steve Powell in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2005, 09:06 PM

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