+ Reply to Thread
Results 1 to 5 of 5

Hide columns on sheet2 based on cell on sheet1?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-17-2009
    Location
    PA USA
    MS-Off Ver
    Excel 2000
    Posts
    184

    Hide columns on sheet2 based on cell on sheet1?

    This is what I would like to do if possible:

    If E9 on Sheet1 is 1, then hide columns F-L on Sheet2.

    Thanks for helping me.

    Excel 2000
    Last edited by proepert; 01-25-2010 at 06:40 AM. Reason: SOLVED

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Hide columns on sheet2 based on cell on sheet1?

    Hi proepert
    In the worksheet1 module
    Private Sub Worksheet_Deactivate()
    If Range("E9") = 1 Then
         Sheets("sheet2").Columns("F:L").EntireColumn.Hidden = True
    Else
    Sheets("sheet2").Columns("F:L").EntireColumn.Hidden = False
    End If
    End Sub
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Hide columns on sheet2 based on cell on sheet1?

    try this code
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("E9")) Is Nothing Then
            If Range("E9") = 1 Then
                Sheets(2).Range("F:L").EntireColumn.Hidden = True
            Else
                Sheets(2).Range("F:L").EntireColumn.Hidden = False
            End If
        End If
    End Sub
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide columns on sheet2 based on cell on sheet1?

    One line
    Option Explicit
    
    Private Sub Worksheet_Deactivate()
         Sheets("sheet2").Columns("F:L").EntireColumn.Hidden = Range("E9").Value
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide columns on sheet2 based on cell on sheet1?

    proepert

    Thanks for the rep.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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