+ Reply to Thread
Results 1 to 6 of 6

Check value and copy the color to a new sheet's cell

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Post Check value and copy the color to a new sheet's cell

    Basically I would like to take the file I've attached and take the Case number, for example 224.4642857, and copy its corresponding color from the Box Height to the new sheet called "Slotting". I have looked online for various code and do not know how to do this. Can someone please help?

    Sub ReColour()
    
    Dim rStart As Range, lRow1 As Long, lRow2 As Long, lRows As Long, sFind As String
    
    Set rStart = Sheet1.Range("A1")
    lRows = rStart.Offset(65000, 0).End(xlUp).Row - rStart.Row
    
    For lRow1 = 1 To lRows
        sFind = rStart.Offset(lRow1, 3).Value
        For lRow2 = 1 To lRows
            If rStart.Offset(lRow2, 0).Value = sFind Then
                rStart.Offset(lRow1, 3).Interior.ColorIndex = rStart.Offset(lRow2, 0).Interior.ColorIndex
                rStart.Offset(lRow1, 4).Interior.ColorIndex = rStart.Offset(lRow2, 1).Interior.ColorIndex
                rStart.Offset(lRow1, 5).Interior.ColorIndex = rStart.Offset(lRow2, 2).Interior.ColorIndex
                Exit For
            End If
        Next
    Next
    End Sub
    Coolstuff.xlsm

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Check value and copy the color to a new sheet's cell

    So first you want to find the case and that isn't working?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: Check value and copy the color to a new sheet's cell

    I can do a vlookup for the Case number but I don't know how to copy the color from the Box Height corresponding to the Case number into a new sheet.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Check value and copy the color to a new sheet's cell

    Option Explicit
    
    Sub ReColour()
    Dim rngCase As Range
    Dim rngLookUpRange As Range
    Dim rw As Range
    Dim cl As Range
    Dim Resp As Variant
    Dim LastRow As Long
    Dim LastCol As Long
    
        With Sheets("Organize")
            Set rngCase = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
        End With
    
        With Worksheets("Slotting")
            LastRow = .Range("A" & Rows.Count).End(xlUp).Row
            LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
            Set rngLookUpRange = .Range("B2", .Cells(LastRow, LastCol))
        End With
    
        For Each cl In rngCase.Cells
            For Each rw In rngLookUpRange.Rows
                Resp = Application.Match(cl.Value, rw, 0)
                If Not IsError(Resp) Then
                    cl.Offset(, 1).Copy
                    rw.Cells(1, Resp).PasteSpecial xlPasteFormats
                    Exit For
                End If
            Next rw
        Next cl
    
        Application.CutCopyMode = False
    
    End Sub

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Check value and copy the color to a new sheet's cell

    Why do you never refer to the other sheet, Slotting, in the code?

  6. #6
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: Check value and copy the color to a new sheet's cell

    Thank you again

+ 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. Check cell Value in range and copy specific cells to another sheet
    By jmethejedi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-08-2013, 06:25 PM
  2. [SOLVED] Copy Cell.Font.Color from Sheet A to corresponding Sheet B
    By chelseasikoebs in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-09-2013, 12:30 AM
  3. [SOLVED] Copy a row to another sheet based on cell fill color
    By swatkins1977 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2012, 02:55 PM
  4. Check cell content has green color then mark as yes in another sheet.
    By dsk_qa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2012, 07:16 AM
  5. Replies: 0
    Last Post: 06-15-2012, 04:15 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