+ Reply to Thread
Results 1 to 4 of 4

VBA Macro to Collapse Rows Based on Value from Cell on another Worksheet

  1. #1
    Registered User
    Join Date
    04-13-2017
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2

    VBA Macro to Collapse Rows Based on Value from Cell on another Worksheet

    Hi All,

    I am new the forum (and macros) and was encouraged to join after struggling a few hours with the below macro! Any sugguestions are greatly appreciated.

    I have been using the below macro to hide and unhide rows when a value is selected from a drop down on the same worksheet, example:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
    If Target.Value = "Y" Then
    Rows("11:12").EntireRow.Hidden = True
    ElseIf Target.Value = "N" Then
    Rows("11:12").EntireRow.Hidden = False
    End If
    End If
    End Sub
    Now, I would like data in Sheet2 to hide/unhide based on the population of cell A1 on Sheet1. I've tried the below, and it is just not working for me!
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = Worksheets("Sheet1").Range("$A$1") Then
    If Target.Value = "Y" Then
    Rows("11:12").EntireRow.Hidden = True
    ElseIf Target.Value = "N" Then
    Rows("11:12").EntireRow.Hidden = False
    End If
    End If
    End Sub
    Thank you!

    Hayley

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Macro to Collapse Rows Based on Value from Cell on another Worksheet

    Will this work...
    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Registered User
    Join Date
    04-13-2017
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2

    Re: VBA Macro to Collapse Rows Based on Value from Cell on another Worksheet

    Thank you! Resolved my issue.

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Macro to Collapse Rows Based on Value from Cell on another Worksheet

    You're welcome, glad it worked for you.

+ 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. Link Pivot Table Collapse/Exapnd to worksheet rows
    By haroblueman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-09-2016, 01:35 AM
  2. collapse columns in conjunction with a collapse rows macro
    By waternut in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2015, 04:50 PM
  3. Macro to expand and collapse rows based on criteria in cells
    By jholiday78 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2015, 10:32 AM
  4. Macro to hide rows on a worksheet, based on a cell's value on another worksheet.
    By buttercup116 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2014, 10:47 AM
  5. Macro to Cut and Paste rows to new worksheet based on cell value
    By kmarkle in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-22-2013, 06:13 AM
  6. Collapse rows based on IF formula results
    By garyma in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-17-2012, 04:51 PM
  7. Replies: 4
    Last Post: 06-14-2006, 07:45 PM

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