+ Reply to Thread
Results 1 to 6 of 6

Unhide Period Columns based on Dropdown list

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    521

    Unhide Period Columns based on Dropdown list

    Hi,

    I need help to unhide 4 columns of a month if I select "Variance" from the dropdown list. At present 3 columns are unhide but I need the % column to unhide.


    Regards,
    Barieq
    Attached Files Attached Files
    Last edited by Barieq; 10-24-2016 at 09:16 AM.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Unhide Period Columns based on Dropdown list

    Hi,

    Is it only Variance that should result in all columns being unhidden? The other options should still only unhide their specific columns?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    521

    Re: Unhide Period Columns based on Dropdown list

    Hi,

    Thanks, I am ok with other options. Only I need the following columns from 12 Periods to be unhide if I select "Variance"

    Budget
    Actual
    Variance
    %

    Regards,

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Unhide Period Columns based on Dropdown list

    Is it acceptable for the code to simply unhide all columns for Variance, or does your real data contain other columns that should remain hidden?

    If all columns may be unhidden, you may simply test for that case
    Private Const colFirst As Long = 2
    Private Const nPeriods As Long = 12
    Private Const colCountGroup As Long = 4
    Private Const colCount As Long = colCountGroup * nPeriods + colCountGroup
    
    Private Enum modeView
        modeViewPlan = 1
        modeViewActual = 2
        modeViewDiff = 3
        modeViewPercent = 4
    End Enum
        
    Private Property Get CurrentView() As modeView
        CurrentView = Application.ThisWorkbook.Names("currentView").RefersToRange.Value
    End Property
    
    Private Sub cmbView_Click()
        Dim nIdx As Long
        Dim nCalcMode As Excel.XlCalculation
        
        nCalcMode = Application.Calculation
        Application.Calculation = xlCalculationManual
        If CurrentView = modeViewDiff Then
            ActiveSheet.Cells.EntireColumn.Hidden = False
        Else
            For nIdx = 1 To colCount
                ActiveSheet.Columns(colFirst + nIdx - 1).Hidden = _
                    Not ((CLng(CurrentView) Or (((nIdx - 1) Mod colCountGroup) + 1)) = CLng(CurrentView))
            Next
        End If
        
        Application.Calculation = nCalcMode
    End Sub

  5. #5
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    521

    Re: Unhide Period Columns based on Dropdown list

    Thanks, No there is no other columns to be hidden. I am ok with your code. It is Solved.

    How can delete my same post which by mistake has been posted twice.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Unhide Period Columns based on Dropdown list

    I imagine the simplest way is to click the Report Post button below your other post and bring it to the moderators' attention as a duplicated posting.

+ 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. Macro to Hide/Unhide Columns Based on a Validation List
    By Legalhustler in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2015, 01:23 PM
  2. Hide/Unhide rows based on Yes or No answers to questions by dropdown list.
    By Johny1 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-12-2015, 06:57 PM
  3. hide/unhide columns based on dropdown list.
    By bg781np in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-18-2013, 07:13 PM
  4. macro to unhide one cell based on the dropdown list value from the cell above
    By famu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2013, 02:00 PM
  5. Automatically Hide/Unhide Columns Based Dropdown List
    By Kapil.gour in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-27-2012, 07:39 AM
  6. Hide/unhide columns based on the drop down list value
    By vagif in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2012, 02:13 AM
  7. Hiding/Unhiding columns based on a dropdown list
    By jim_0068 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2007, 11:57 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