Consulting

Results 1 to 2 of 2

Thread: Copy Highlighted Cell to Another Worksheet

  1. #1

    Copy Highlighted Cell to Another Worksheet

    I have tried doing this:

    Sub MoveHighlightedErrors()
    
    
    Dim rowIndex As Long
    
    
    rowIndex = 3
    
    
    
    
    With Sheets("Sheet1")
    
    
    For i = 4 To .Range("E4").CurrentRegion.Rows.Count
        If .Cells(i, 9).Interior.Color = 65535 And .Cells(i, 11).Interior.Color = 65535 Then
        Sheets("Sheet1").Range(.Cells(i, 5), .Cells(i, 11)).Copy Destination:=Sheets("Sheet2").Rows(rowIndex)
        rowIndex = rowIndex + 1
        End If
    Next i
    
    
    End With
    
    
    End Sub
    Which unfortunately doesn't work. I'm not sure how to properly read a highlighted cell.

    Columns I and K could be highlighted. If they are both highlighted, I want to copy columns E:K for that row, and copy it to Sheet2 starting on row 3.


    *Edit
    The highlighted cells are conditionally formatted
    Last edited by spencerp237; 03-23-2017 at 09:17 AM.

  2. #2
    VBAX Regular JBeaucaire's Avatar
    Joined
    Sep 2014
    Location
    Bakersfield
    Posts
    32
    Location
    Color isn't data. Typically you use the same CF logic you used to color the cell to also inform your macro. So if your CF formula is looking for values < 100, then your macro would do the same thing, etc.
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •