+ Reply to Thread
Results 1 to 9 of 9

VBA to hide rows where no cells are highlighted

  1. #1
    Registered User
    Join Date
    06-15-2020
    Location
    London, Ontario
    MS-Off Ver
    2016
    Posts
    4

    Red face VBA to hide rows where no cells are highlighted

    Hello! I'm new to this Forum and new to VBA. I have a large list of data in multiple columns (columns B to F) and several rows (2 to 20,000). I have highlighted the cells (in Red RGB (255, 0, 0)) that contain 0.00 and I want to hide any rows that do not have a highlighted cell. The below code is what I have but it just hides all the rows. Can someone help me figure out what I have wrong. Thanks!
    Please Login or Register  to view this content.
    Last edited by alansidman; 06-15-2020 at 04:40 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,865

    Re: VBA to hide rows where no cells are highlighted

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: VBA to hide rows where no cells are highlighted

    Quote Originally Posted by MrsT. View Post
    ... I have highlighted the cells ... that contain 0.00 ... want to hide any rows that do not have a highlighted cell ...
    Which rows in this below data layout should be hidden and which not ?
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    06-15-2020
    Location
    London, Ontario
    MS-Off Ver
    2016
    Posts
    4

    Re: VBA to hide rows where no cells are highlighted

    I want to see all zeros. Thank you!

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to hide rows where no cells are highlighted

    Not tested but maybe:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  6. #6
    Registered User
    Join Date
    06-15-2020
    Location
    London, Ontario
    MS-Off Ver
    2016
    Posts
    4

    Re: VBA to hide rows where no cells are highlighted

    Thank you! I tried this code. I received an error "Run-Time Error '13': Type Mismatch".
    This is the part of the code that is highlighted:
    If Q(r, c) = 0 Then

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to hide rows where no cells are highlighted

    If this doesn't fix it:

    Please Login or Register  to view this content.
    then
    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  8. #8
    Registered User
    Join Date
    06-15-2020
    Location
    London, Ontario
    MS-Off Ver
    2016
    Posts
    4

    Re: VBA to hide rows where no cells are highlighted

    This worked perfectly and efficiently. Thank you so much!!

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to hide rows where no cells are highlighted

    You're welcome and thanks for the rep!

+ 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. delete rows highlighted with cells in A coulmn
    By kumarsandeep99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2019, 08:56 AM
  2. Selecting rows with highlighted cells
    By jsuma in forum Excel General
    Replies: 3
    Last Post: 10-06-2014, 02:34 PM
  3. [SOLVED] First unhide all rows - then hide rows based on specific cell value for a range of cells
    By robbiekh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-22-2013, 05:46 PM
  4. Move rows to another sheet based on highlighted cells
    By LongShanks in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-08-2013, 10:29 PM
  5. [SOLVED] Conditional format to hide 0 w Odd,Even rows highlighted.
    By JO505 in forum Excel General
    Replies: 4
    Last Post: 03-03-2013, 08:19 PM
  6. HIDE ZEROS IN CHART - Hide rows of cells that equals zero
    By sweedey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2011, 08:18 PM
  7. Count number of filled cells between lines of highlighted rows
    By vzc8 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-25-2011, 01:38 PM

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