• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Visual Basic Code to copy cell color

Jaimee001

Member
Hello team!
I have a rather large excel report that is color coded. I did a vlookup to append data to that report, however, I'm not able to figure out how to append/format the cell color. The attached example report has 4 different colors but the actual report has 8 and it has to be based on the acct column. I'm not very versed in VB and have only done it a few times. Can someone help me with the code? I've attached an example report.
Thank you so much!
 

Attachments

Since you don't have code, I'm just showing you example.

Also, since you have quite a few Conditional Formats in Column B, we can't use PasteSpecial method.

See if code below does what you are looking for.
Code:
Sub PasteColor()
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
lRow = ws.Range("B" & Rows.Count).End(xlUp).Row
For Each Cell In ws.Range("B1:B" & lRow)
    ws.Range("C" & Cell.Row).Interior.Color = Cell.Interior.Color
Next Cell
End Sub
 
Back
Top