Results 1 to 9 of 9

VBA to hide rows where no cells are highlighted

Threaded View

MrsT. VBA to hide rows where no... 06-15-2020, 03:05 PM
alansidman Re: VBA to hide rows where no... 06-15-2020, 04:40 PM
mjr veverka Re: VBA to hide rows where no... 06-15-2020, 04:59 PM
MrsT. Re: VBA to hide rows where no... 06-16-2020, 11:23 AM
xladept Re: VBA to hide rows where no... 06-16-2020, 11:40 AM
MrsT. Re: VBA to hide rows where no... 06-16-2020, 03:07 PM
xladept Re: VBA to hide rows where no... 06-16-2020, 03:16 PM
MrsT. Re: VBA to hide rows where no... 06-16-2020, 03:27 PM
xladept Re: VBA to hide rows where no... 06-16-2020, 03:32 PM
  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!
    Private Sub CommandButton1_Click()
    
    Dim active_worksheet As Worksheet
    Dim c As Integer
    Dim r As Integer
    Dim count As Integer
    count = 0
    For r = 2 To 20000
    For c = 2 To 6
    If Cells(r, c).Interior.ColorIndex = RGB(255, 0, 0) Then
    count = 1
    End If
    Next c
    If count = 0 Then
    Rows(r).Hidden = True
    End If
    count = 0
    Next r
    End Sub
    Last edited by alansidman; 06-15-2020 at 04:40 PM.

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