Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
while comparing two columns A and B I am able to highlight the unique data in both the columns using conditional formatting but now the problem is that I want to copy and paste this highlighted data from B into the column A so I am looking forward for a VBA code that can do this task of copying the highlighted data from Column B and paste it into the column A

Like
A12= dog
B12= cat
B12 is highlighted with RED using conditional formatting
so IF highlighted with RED, B12=A12
final output:
B12=cat
A12=cat

What I have tried:

I know how to copy data from one cell to another

Sub CopyValue()
ActiveSheet.Range("A12").Value = ActiveSheet.Range("B12")
End Sub

But how to apply the after highlighted part is a little difficult as I have no idea of VBA.
Posted
Updated 16-Aug-18 5:39am

1 solution

You don't actually have to look for "RED".

You are using "conditional formatting"; therefore, test the "condition" (not the color).

In any event, here's a "color" link:

Get Excel cell style in VB[^]
 
Share this answer
 
Comments
bhargavsingh4821 17-Aug-18 4:39am    
Sorry but I dint get this post The problem here is how to test that condition and copy that highlighted cell's data to the cell from which its comparing.
CHill60 5-Sep-18 5:13am    
I was just about to answer your other question about moving a button when you type data into a list, but the question has been deleted.
If it is still a problem then post it again and reply to this comment and I will post a solution for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900