我有一个电子表格,其中包含许多列,我想确定在所有列中通用的所有行。无论这是通过突出显示还是创建另一列,我都没有偏好。同样,公式或宏也同样可以接受。确定跨列的所有常见行
作为一个例子,
-------------------------------------- | List 1 | List 2 | List 3 | List 4 | -------------------------------------- | Bill | Carlos | Adam | Adam | | Carlos | Dan | Bill | Carlos | | Frank | Frank | Carlos | Frank | | | Gerard | Frank | Liam | | | | Jim | | --------------------------------------
在上述我想,以确定卡洛斯和Frank是跨所有列共用的例子。
注意所有列都是排序和唯一的。
我目前通过macro组织这些项目,它们跨栏排列。我从这个角度假定,使用conditional formatting突出显示所有空白行很容易,但无法完成此操作。也许我以错误的方式去解决这个问题。
宏代码:
Option Explicit
Sub LineEmUp()
'Author: Jerry Beaucaire
'Date: 7/5/2010
'Summary: Line up a random number of columns so all matching
' items are on the same rows
Dim LC As Long
Dim Col As Long
Dim LR As Long
Application.ScreenUpdating = False
'Spot last column of data
LC = Cells(1, Columns.Count).End(xlToLeft).Column
'Add new key column to collect unique values
Cells(1, LC + 1) = "Key"
For Col = 1 To LC
Range(Cells(2, Col), Cells(Rows.Count, Col)).SpecialCells(xlConstants).Copy _
Cells(Rows.Count, LC + 1).End(xlUp).Offset(1)
Next Col
Columns(LC + 1).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Cells(1, LC + 2), Unique:=True
Columns(LC + 2).Sort Key1:=Cells(2, LC + 2), Order1:=xlAscending, Header:=xlYes
'Fill in new table headers w/formatting
Range("A1", Cells(1, LC)).Copy Cells(1, LC + 3)
'Fill in new table values
LR = Cells(Rows.Count, LC + 2).End(xlUp).Row
With Range(Cells(2, LC + 3), Cells(LR, LC + 2 + LC))
.FormulaR1C1 = "=IF(ISNUMBER(MATCH(RC" & LC + 2 & ",C[-" & LC + 2 _
& "],0)), RC" & LC + 2 & ", """")"
.Value = .Value
End With
'Cleanup/Erase old values
Range("A1", Cells(1, LC + 2)).EntireColumn.Delete xlShiftToLeft
Columns.Autofit
Application.ScreenUpdating = True
End Sub
那么你自己做了什么来完成这件事?我们不在这里为你做你的工作 - 你必须自己投入至少一些努力。 –
对不起,我没有意识到我现在需要通过证明我已经进行适当调查的资格。我会更新。 – McArthey
不,但是直到你表明你已经为此付出了一些努力,我们可以自由地假设:“是的,其他人希望美国为他们做他们的工作”。 –