我有一個電子表格,其中包含許多列,我想確定在所有列中通用的所有行。無論這是通過突出顯示還是創建另一列,我都沒有偏好。同樣,公式或宏也同樣可以接受。確定跨列的所有常見行
作爲一個例子,
-------------------------------------- | 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
不,但是直到你表明你已經爲此付出了一些努力,我們可以自由地假設:「是的,其他人希望美國爲他們做他們的工作」。 –