+ Reply to Thread
Results 1 to 3 of 3

Hide/Unhide Rows & Colums based on Separate range

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Hide/Unhide Rows & Colums based on Separate range

    Hello everyone,

    I have a Workbook with several different Sheets. All sheets are formatted exactly the same.

    In the sheet I have a range B3:B15 - it contains one of three values - 2, 1, 0.
    Based on this range I want to Hide specific columns and rows if value is equal "0" and unhide it if it is either "1" or "2".

    For example:
    If B3 = 0 Then Hide Column "F" and Hide Row "11", Else Show Column "F" and Show Row "11"

    I want to create a Macros that will be constantly running and checking the values in the range or run itself as soon as a value in the range changes.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Hide/Unhide Rows & Colums based on Separate range

    Whether the code should do be compatible to run on each sheet whenever any change on those sheets? or the code needs to be applied for that sheet alone?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Hide/Unhide Rows & Colums based on Separate range

    I think it should only run it on the active spreadsheet. It would make more sense since the Range on the page affects directly only content on that same page.

    I've created a simplistic macros last night, apologies for any errors in code, I'm new to VBA:


    Select.Range("B3")

    If ActiveCell = "0" Then

    Rows("11").EntireRow.Hidden = True
    Columns("F").EntireColumn.Hidden = True

    Else

    Rows("11").EntireRow.Hidden = False
    Columns("F").EntireColumn.Hidden = False

    End If


    I've copied and changed this code 13 times for all cells in range B3:B15
    It does what I want but I have to re-run the macros manually.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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