【发布时间】:2016-12-22 10:27:26
【问题描述】:
Excel 2007 [VB] 在我的宏中,我按颜色过滤以查找重复值(在“J”列上,我有突出显示单元格规则 - 重复项)。 “J”列中的重复记录在“K”列中命名为“副本”或“原始”。我想为每个始终位于(但不是 1 行而是更多行)下的“原始”记录找到“副本”和将“复制”行的 N:R 列中的单元格值复制到“原始”行。
我希望我写的清楚,但如果不是截图下。
表格
我的宏开始:
Sub copy_original()
Dim lastRow As Long
Dim wb2 As Excel.Workbook
Application.DisplayAlerts = False
Application.AlertBeforeOverwriting = False
Application.ScreenUpdating = True
Set wb2 = ThisWorkbook
wb2.Sheets("Sheet1").AutoFilterMode = False
wb2.Sheets("Sheet1").Range("A4:U4").AutoFilter Field:=10, Criteria1:=RGB(255, 204, 0), Operator:=xlFilterCellColor
lastRow = wb2.Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
For x = lastRow To 5 Step -1
If...
...
wb2.Sheets("Sheet1").AutoFilterMode = False
End Sub
我寻找可以提供帮助的类似内容,并找到了这样的脚本:
Check if one cell contains the EXACT same data as another cell VBA
Find cells with same value within one column and return values from separate column of same row
Excel: Check if Cell value exists in Column, and return a value in the same row but different column
但老实说,我不知道如何将它连接到一个工作宏中。 我将不胜感激。
【问题讨论】: