+ Reply to Thread
Results 1 to 9 of 9

Need help using Cell contents for Range of Rows to be Hidden - Would INDIRECT work?

Hybrid View

rguliuzza Need help using Cell contents... 12-06-2013, 03:28 PM
kelleytr Re: Probably making it too... 12-06-2013, 04:19 PM
rguliuzza Re: Probably making it too... 12-06-2013, 04:32 PM
natefarm Re: Probably making it too... 12-06-2013, 04:43 PM
rguliuzza Re: Probably making it too... 12-06-2013, 05:02 PM
FDibbins Re: Need help using Cell... 12-06-2013, 06:43 PM
rguliuzza Re: Need help using Cell... 12-06-2013, 07:14 PM
kelleytr Re: Need help using Cell... 12-09-2013, 02:33 PM
rguliuzza Re: Probably making it too... 12-06-2013, 05:26 PM
  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Santa Clara, CA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Need help using Cell contents for Range of Rows to be Hidden - Would INDIRECT work?

    I have a spreadsheet for creating a quote with a number of dropdown choices. Once the dropdown choice is made, a number of the rows are hidden by using the following formula:
    Private Sub Worksheet_Change(ByVal Target As Range)
     If Intersect(Target, Me.Range("C18")) Is Nothing Then Exit Sub
     Application.EnableEvents = False 'to prevent endless loop
     Rows("1:2000").EntireRow.Hidden = False
     If Range("$C$18").Value = "G3LabUniversalDV" Then
     Range("63:122").EntireRow.Hidden = True
     Range("195:396").EntireRow.Hidden = True
     Range("1249:1265").EntireRow.Hidden = True
     Range("1301:1302").EntireRow.Hidden = True
     End If
     If Range("$C$18").Value = "G3LabUniversalPC" Then
     Range("123:396").EntireRow.Hidden = True
     Range("1071:1248").EntireRow.Hidden = True
     Range("1296:1300").EntireRow.Hidden = True
     End If
     If Range("$C$18").Value = "G3ProUniversal" Then
     Range("63:194").EntireRow.Hidden = True
     Range("272:359").EntireRow.Hidden = True
     Range("1249:1265").EntireRow.Hidden = True
     Range("1301:1302").EntireRow.Hidden = True
     End If
     If Range("$C$18").Value = "G3PC" Then
     Range("63:271").EntireRow.Hidden = True
     Range("1071:1248").EntireRow.Hidden = True
     Range("1296:1300").EntireRow.Hidden = True
     End If
     Application.EnableEvents = True
     End Sub
    What I am having a problem with is when I add a Row to the Spreadsheet, these sections are not automatically updated and I have to go back and enter in all the new ranges by hand. Is there an easier way to do this? In addition to this, am I able to use and formula name for the range and just change the formula when a row is entered? Please help!
    Last edited by rguliuzza; 12-06-2013 at 05:30 PM. Reason: Original Title was vague.

  2. #2
    Registered User
    Join Date
    05-23-2013
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Probably making it too complicated - need help!

    Is there anything unique about the starting and ending rows for those ranges? If so you could have them dynamically created using a match function.

  3. #3
    Registered User
    Join Date
    09-06-2012
    Location
    Santa Clara, CA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Probably making it too complicated - need help!

    Hi Kelley,

    The rows are just products that we provide for use in our Quote tool and based on the drop-down, I want to hide the rows not needed to narrow the tool down a little. It is a little daunting to look through 1500 line items and although you can search for each one, this would save some time.

    I am not familiar with the MATCH function in this case. As you can see by the code, there are arrays of rows to hide and when I add three products into the mix, it is not intuitive enough to expand the arrays.

    Oh well, if you have an example of the MATCH function in light of this issue, I would welcome it.

    Thank you for your response.

    With best regards,
    Rick

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Probably making it too complicated - need help!

    I would suggest naming your ranges, and to make it easy, use VBA to do it. Copy and paste the following into a code module(replace Sheet1 with your sheet name):
    Sub CreateNames()
        ActiveWorkbook.Names.Add Name:="G3LabUniversalDV", RefersToR1C1:="=Sheet1!R63:R122,Sheet1!R195:R396,Sheet1!R1249:R1265,Sheet1!R1301:R1302"
    End Sub
    Copy and paste the code line 3 times and adjust the copies for your other three ranges. Then run the code to create the names. Then replace all your code above with:
    Private Sub Worksheet_Change(ByVal Target As Range)
       If Intersect(Target, Me.Range("C18")) Is Nothing Then Exit Sub
       Application.EnableEvents = False ' I don't know if this is still needed or not
       Rows("1:2000").EntireRow.Hidden = False
       Range(Range("C18").value).EntireRow.Hidden=true
    end sub
    I haven't tested this entirely, but it should be close.

  5. #5
    Registered User
    Join Date
    09-06-2012
    Location
    Santa Clara, CA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Probably making it too complicated - need help!

    Hi Nate,

    I appreciate the code and will try it out. Sometimes I need more eyes on the issue.

    Thank you again,
    Rick

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Need help using Cell contents for Range of Rows to be Hidden - Would INDIRECT work?

    Once the title is changed, I can recover the post I removed

    edit: Thanks for ther title change
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Registered User
    Join Date
    09-06-2012
    Location
    Santa Clara, CA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Need help using Cell contents for Range of Rows to be Hidden - Would INDIRECT work?

    Thank you!

  8. #8
    Registered User
    Join Date
    05-23-2013
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Need help using Cell contents for Range of Rows to be Hidden - Would INDIRECT work?

    rguliuzza,

    Were you able find a solution using NateFarms suggestion? If not then I can spend some more time on it.

  9. #9
    Registered User
    Join Date
    09-06-2012
    Location
    Santa Clara, CA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Probably making it too complicated - need help!

    Hello FDibbins,

    I apologize for an incorrect post. I will update the title and it looks like you already edited the code?

    Thank you,
    Rick

+ 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] making dropdown list wider without making cell wider ???
    By wayneg in forum Excel General
    Replies: 16
    Last Post: 05-20-2021, 12:53 AM
  2. [SOLVED] (QUITE) Complicated Syntax involving IF and REPEAT (Making a money budget excel file)
    By alexbui.2539 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-02-2013, 10:04 PM
  3. [SOLVED] Complicated Look Up (without making changes to the values in the table)
    By Excel Dumbo in forum Excel General
    Replies: 9
    Last Post: 10-19-2012, 01:31 AM
  4. making a spreadsheet for student coursework making
    By spartan11chin in forum Excel General
    Replies: 17
    Last Post: 12-01-2009, 08:18 AM
  5. making a complicated bar graph
    By harrygorilla in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-08-2006, 12:25 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