+ Reply to Thread
Results 1 to 9 of 9

need help re hiding rows in a range based on cell contents

  1. #1
    Registered User
    Join Date
    10-10-2003
    Posts
    31

    need help re hiding rows in a range based on cell contents

    In Excel 2010 I have a single-column range (1x50) whose cells each contain zero up to a few short alphanumeric snippets separated by spaces (eg: etf, ad, etf 3m5, f hei7, etfg ...etc.). I need a VBA function which, when aimed at the range, hides (or un-hides) every row in which a specific snippet is found. If the snippet is "etf", both the cell with "etf" and the cell with "etf 3m5" above would be hidden, but the cell with "etfg" would not. If no snippet is provided, every row in the range is hidden.

    The pseudo-code below lays out the logic I think, but I need help translating that into Excel 2010 VBA code. Assistance very much appreciated. - Jim

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: need help re hiding rows in a range based on cell contents

    Jim,
    A function returns a value in VBA, but it does not hide a cell (Action). What you need is a procedure-i.e a sub procedure. I think it would be easier to test a code if you could attach a sample excel book.

  3. #3
    Registered User
    Join Date
    10-10-2003
    Posts
    31

    Re: need help re hiding rows in a range based on cell contents

    AB33 - Quite right re proc vs func - not thinking clearly here. Revised spec on attached worksheet. Thanks! - Jim
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: need help re hiding rows in a range based on cell contents

    Jim,
    why can not use a simple code? I am sure I am missing something

    Please Login or Register  to view this content.
    You can also use the istr function,but I am not sure If I follow your data

  5. #5
    Registered User
    Join Date
    10-10-2003
    Posts
    31

    Re: need help re hiding rows in a range based on cell contents

    AB33 - I appreciate your help, but I think we lack common ground on what I'm trying to do. Let's see if someone else out there will chime in to sort me out. - Jim

  6. #6
    Registered User
    Join Date
    10-10-2003
    Posts
    31

    Re: need help re hiding rows in a range based on cell contents

    AB33 - I appreciate your help, but I think we lack common ground on what I'm trying to do. Let's see if someone else out there will chime in to sort me out. - Jim

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: need help re hiding rows in a range based on cell contents

    hi jimredfield, please check attachment, try to change value in C3 and D3 or one of them
    Attached Files Attached Files
    Last edited by watersev; 12-30-2012 at 01:05 AM.

  8. #8
    Registered User
    Join Date
    10-10-2003
    Posts
    31

    Re: need help re hiding rows in a range based on cell contents

    Waterserv - Perfect solution, and with coding shortcuts/efficiencies well beyond my modest understanding of VBA. I also appreciate the error trapping. Thanks very much. (I remember seeing a drop-down that provided an opportunity to mark a thread 'solved' but I can't seem to find it. Aim me in the right direction and I'll do so for this thread, or feel free to do it at your end on my behalf.) - Jim

  9. #9
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: need help re hiding rows in a range based on cell contents

    as per Forum Rules:

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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