+ Reply to Thread
Results 1 to 13 of 13

Hide Multiple Rows Based upon a variable

  1. #1
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Question Hide Multiple Rows Based upon a variable

    I would like to define a variable that is comprised of (3) rows (that is why I am using the resize(3,1) command) - but the range location is unknown so I have to used the find command.

    Please Login or Register  to view this content.

    I dont know if that is correct or not. Do I use ".Row" or ".Rows" since its more than one?

    Then once that range is found, I am writing a if statment that will do the following:
    Please Login or Register  to view this content.

    But of coarse, this isnt working correctly, so hence my post. How do I accomplish this correctly?

    Thanks in advance.
    Last edited by clemsoncooz; 02-22-2012 at 12:40 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363

    Re: Hide Multiple Rows Based upon a variable

    Would this work for you?
    Please Login or Register  to view this content.
    Denis

    Please always attach the sample workbook without sensitive information when asking for help

    To add a module
    Press Alt + F11 (this is the Visual Basic Environment)
    Insert Menu, select Module
    Past code there
    Close Visual Basic Environment (X)

  3. #3
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: Hide Multiple Rows Based upon a variable

    Hello jetted.

    Thanks for the reply and looking at this.

    I dont think that will do it.

    But I did notice that my xyz_rows should be range and not long. So thanks for that tid bit.

    So now I am trying this and it doesnt work:
    Please Login or Register  to view this content.
    I get error 1004. Method 'Range' of Object'_ worksheet; failed.

  4. #4
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: Hide Multiple Rows Based upon a variable

    so why does this fail:
    Please Login or Register  to view this content.

    Run-Time Error '91'
    Object variable or with block variable not set
    Last edited by clemsoncooz; 02-22-2012 at 11:55 AM.

  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Hide Multiple Rows Based upon a variable

    Please Login or Register  to view this content.
    Good luck.

  6. #6
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: Hide Multiple Rows Based upon a variable

    OnErrorGoto0

    I took your advice and tried to use that exactly.

    Are you able to see what is wrong with this because I am still getting Run-Time Erro '91' Object variable or With block variable not set....

    Please Login or Register  to view this content.

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Hide Multiple Rows Based upon a variable

    Perhaps you are not finding the text:
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: Hide Multiple Rows Based upon a variable

    OK - so I tried that and did get the msgbox - so I guess its not finding the text.

    Doesn't the find command look within HIDDEN ROWS?

    Because I know "Design Review" is located in C45 - its just that Row 45 is hidden since I ran the code testing to see if it would hide that row - now I am trying the reverse to unhide it.

  9. #9
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Hide Multiple Rows Based upon a variable

    Change xlValues to xlFormulas

  10. #10
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: Hide Multiple Rows Based upon a variable

    Appears to be working.

    So when using find - xlformulas will look in hidden rows/columns but xlvalues will not? Is that correct?

  11. #11
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Hide Multiple Rows Based upon a variable

    Yes. xlValues is closely linked to formatted values, I think, which is why it has the problem.

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Hide Multiple Rows Based upon a variable

    Please Login or Register  to view this content.
    Last edited by snb; 02-22-2012 at 12:57 PM.



  13. #13
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Hide Multiple Rows Based upon a variable

    Pros:
    None, really, though it's shorter (if you're worried about keyboard wear and tear, maybe)

    Cons:
    No error handling
    Inflexible
    Harder to read and maintain.

    Your call.

+ 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