+ Reply to Thread
Results 1 to 17 of 17

Hide row based on cell value

  1. #1
    Forum Contributor
    Join Date
    09-08-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    122

    Hide row based on cell value

    Hi Experts,

    Can someone please improve the code below.
    What it does is search a column for "Yes" and then hide that row.

    The below code works perfectly however now that i am doing over 2000 rows that needs to be hidden it runs very slow.
    Is there a way to speed it up?


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    "Is there a way to speed it up?" yes certainly
    Which column is it used to search for "Yes" ?
    The best would be to have a sample Excel file
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    Try

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-08-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    122

    Re: Hide row based on cell value

    Hi PCI,
    Your code works perfectly,
    Can you please explain more about " set hiderg = union (hiderg, f)"

    This is something new to me and I would like to understand so that I can use it in other codes.

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    Please Login or Register  to view this content.
    It requests the range HideRg to be "merged" with range F into HideRg
    Final HideRg is the union of Original HideRg and F

  6. #6
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Hide row based on cell value

    As the HideRg could also be empty, change the line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    Thank you berlan, that's true it could happen there is no "Yes"

  8. #8
    Forum Contributor
    Join Date
    09-08-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    122

    Re: Hide row based on cell value

    Thank you,
    So this means I could use this same code with a slight modification to copy the found rows to a new worksheet or move a offset value?

  9. #9
    Forum Contributor
    Join Date
    09-08-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    122

    Re: Hide row based on cell value

    I have been testing out the VBA code and I am impressed with the speed and flexibility of options.
    Please Login or Register  to view this content.
    Now i am just being greedy here but how would you apply wildcards to
    Please Login or Register  to view this content.
    and also what happens if I have multiple values that i want the same action taken on? example
    Please Login or Register  to view this content.
    ,
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    Some comments:
    next code seems curious, is used HideRg in HideRg
    Please Login or Register  to view this content.
    Some questions
    about wildcards is it to use with "Yes" and "no" and "maybe"

  11. #11
    Forum Contributor
    Join Date
    09-08-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    122

    Re: Hide row based on cell value

    I would like to add a wild card search so that it will pick up "yesterday" " yes" or "yesteryear".

    The yes no and maybe is for when I want to search for multiple strings.

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    "with a slight modification to copy the found rows to a new worksheet or move a offset value? "
    Yes, here a suggestion: NOT TESTED
    Please Login or Register  to view this content.

  13. #13
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    Here we are
    Concerning the second macro (Yes + wildcards ) no matter if it is upper or lower case
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    09-08-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    122

    Re: Hide row based on cell value

    Hi PCI,

    Your code works flawlessly.

    Can I get further explanation of
    Please Login or Register  to view this content.
    ?

  15. #15
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    Please Login or Register  to view this content.
    We have to check if F.value contains the string WdStg = "Yes"
    We change the 2 strings in uppercase using UCase
    We replace WdStg by nothing in F if it exist, therefore the length of F.value (Len(Replace(UCase(F.Value), UCase(WdStg), "")) should be reduced and different to the original length (Len(F.Value) )

  16. #16
    Forum Contributor
    Join Date
    09-08-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    122

    Re: Hide row based on cell value

    Hi PCI,

    Thank you for the explanation.
    You should be a teacher, i now understand

  17. #17
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Hide row based on cell value

    Thank you.
    The reward is your thanks and my satisfaction when you have understood.

+ 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. Replies: 2
    Last Post: 07-27-2014, 11:48 PM
  2. Row hide based on cell value
    By jonmckennawait in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-23-2014, 02:15 PM
  3. Hide multiple rows below target cell based on a cell value match elsewhere.
    By tapmagoo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2013, 12:37 PM
  4. [SOLVED] Hide Row based on value of cell
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-20-2012, 04:43 PM
  5. Re: Is there a way to HIDE a row based on a value of a cell ?
    By Norman Jones in forum Excel General
    Replies: 0
    Last Post: 01-25-2005, 11:06 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