如果使用条件格式突出显示数据,则如何将数据从列复制并粘贴到另一列 [英] How to copy and paste data from a column into another column if it is highlighted using conditional formatting

查看:418
本文介绍了如果使用条件格式突出显示数据,则如何将数据从列复制并粘贴到另一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在比较两列A和BI时,能够使用条件格式突出显示两列中的唯一数据,但现在的问题是我想将这个突出显示的数据从B复制并粘贴到A列中,所以我很期待对于VBA代码,可以执行此任务从B列复制突出显示的数据并将其粘贴到A列中





A12 =狗

B12 =猫

B12用红色突出显示使用条件格式

所以IF用RED突出显示,B12 = A12

最终输出:

B12 =猫

A12 =猫



我是什么尝试过:



我知道如何将数据从一个单元格复制到另一个单元格



Sub CopyValue()

ActiveSheet.Range(A12)。Value = ActiveSheet.Range(B12)

End Sub



但是如何应用后突出显示的部分有点困难,因为我不知道VBA。

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.

推荐答案

你实际上不需要寻找RED。



你正在使用条件格式化;因此,测试条件(不是颜色)。



无论如何,这是一个颜色链接:



在VB中获取Excel单元格样式 [ ^ ]
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[^]


这篇关于如果使用条件格式突出显示数据,则如何将数据从列复制并粘贴到另一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆