+ Reply to Thread
Results 1 to 7 of 7

Macro: Hide Row If Two Cells Dont Start The Same

  1. #1
    Forum Contributor
    Join Date
    08-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    146

    Macro: Hide Row If Two Cells Dont Start The Same

    So I'm looking to market to a list of people local for my families new ice cream shop! I have a list of people and want to know which address to mail to. On the list I'd like to hide all rows where the cell in H does NOT equal the cell in E. The list I have sometimes has the same address but witten differently as seen in E4 and H4; AVENUE and AVE. I figured the easiest way to circumvent this is to compare the first few characters of both cells being compared and hide if they dont start the same. If theres another way such as compare entire cell in E and if H contains the same then hide it. Any suggestions would be greatly appreciated. I found a similar code I didnt modifty yet which might help:

    Please Login or Register  to view this content.
    I know it is comparing just cell E1 so I dont know how to modify to cycle through all cells for the comparison in E and H. FYI I'd like to use this macro again in the future and I'm assuming the list size will change from list to list.
    Attached Files Attached Files

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

    Re: Macro: Hide Row If Two Cells Dont Start The Same

    Try
    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Contributor
    Join Date
    08-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    146

    Re: Macro: Hide Row If Two Cells Dont Start The Same

    PCI I assigned this macro to a button and ran it but its hiding all of the cells that are not similar. I apologize if I explained it bad in my first post but I'm actually looking to do the exact opposite of what the code you entered. Do you know what the code for that would look like? Is it true I'd just delete the "Not"?

    Also, what do you think a code which uses the criteria that the first 3 characters of the cell in E must match H otherwise it hides the row would look like?
    Last edited by excel2425; 03-19-2016 at 11:13 PM.

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

    Re: Macro: Hide Row If Two Cells Dont Start The Same

    It was not completely clear for me but I reuse the code you sent to stay in you needs
    "Is it true I'd just delete the "Not"?" => YES, just try and you will see
    If you want to test just the first 3 characters, see next code
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    146

    Re: Macro: Hide Row If Two Cells Dont Start The Same

    PCI Both of those solutions look to work out perfectly! I have one last question then I'll mark as solved. Do you know how I could quickly unhide all? I tried clicking all rows, right-click unhide and it didnt work. I also tried clicking a section and went to Format>Hide & Unhide> Unhide Rows and nothing happened. I set a section of hidden cells height to 15 as well and nothing. THe only way it seems like I'd be able to unhide at this moment is to double click inbetween each cell this is hidden. Its not a big deal but it's always nice to doulbe check the formula is hiding the proper rows.

  6. #6
    Forum Contributor
    Join Date
    08-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    146

    Re: Macro: Hide Row If Two Cells Dont Start The Same

    Nevermind, it was that the filter was messing it up. Man that was annoying but I got it!

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

    Re: Macro: Hide Row If Two Cells Dont Start The Same

    Not sure you need to unhide the rows because the way the macros are working:
    They first unhide the row, then do the check, then hide the row if the check is positive

+ 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. Dont even know where to start, maybe an if??
    By burnsie in forum Excel General
    Replies: 8
    Last Post: 02-20-2015, 08:15 AM
  2. Why dont we start discussion on renewable Energy sources?
    By synodbio in forum The Water Cooler
    Replies: 22
    Last Post: 12-18-2013, 05:45 AM
  3. Replies: 3
    Last Post: 09-23-2013, 11:49 PM
  4. [SOLVED] Dont hide a sheet
    By pauldaddyadams in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-18-2013, 04:49 AM
  5. Macro to format cells, adjust column widths, hide cells
    By amsolmyers in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2010, 04:44 PM
  6. Replies: 1
    Last Post: 12-14-2009, 05:20 PM
  7. Determine currently selected cells at start of macro
    By Piers 2k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2005, 10:06 AM

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