+ Reply to Thread
Results 1 to 4 of 4

VBA: If 2 cells in Row are yellow Delete last

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    VBA: If 2 cells in Row are yellow Delete last

    I need to add a part to my macro. I need it to go through each row and if there are two yellow filled cells next to each other, then delete the second. The yellow is .color = 10092543. How can I do this in VBA. Thanks for help.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA: If 2 cells in Row are yellow Delete last

    Maybe:

    Sub mattress58y()
    Dim i As Long
    Application.ScreenUpdating = False
    For i = ActiveSheet.UsedRange.Rows.count + 1 To 2 Step -1
        For Each cell In Range(Cells(i, 1), Cells(i, ActiveSheet.UsedRange.Columns.count + 1))
            If cell.Interior.Color = 10092543 And cell.Offset(, 1).Interior.Color = 10092543 Then
                cell.Offset(, 1).Clear
            End If
        Next cell
    Next i
    Application.ScreenUpdating = True
    End Sub

  3. #3
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: VBA: If 2 cells in Row are yellow Delete last

    YOU ARE THE MAN!!!! That worked!!!! Thanks

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA: If 2 cells in Row are yellow Delete last

    You're welcome. Glad to help out and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. 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)

Similar Threads

  1. [SOLVED] Delete entire column if it does not contain a cell highlighted yellow
    By boorama in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-14-2013, 03:13 AM
  2. [SOLVED] Highlight Yellow Active Row, PROBLEM: row selected before closing stays yellow
    By NumberCruncher311 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-12-2013, 07:01 PM
  3. Highlight blank cells in yellow.
    By n_lindsey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2013, 02:17 AM
  4. Reassiging yellow color to cells
    By lokechoiwun in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2006, 09:26 AM
  5. only cells that are colored yellow
    By childothe1980s in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2006, 01:00 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