我有这样的数据
A B C D
1. Customer T/C NET VAT
2. Sandy T1
3. Sandy T5
4. Sandy T1
5. Sandy T5
6. Candy T1
7. Candy T5
8. Dandy T5
9. Dandy T1
其中NET
和VAT
包含$Amount
&1,2
等为行号&T1/T5为税号
摘要列
R S T
1. Customer T5NET T5VAT
2. Sandy
3. Candy
4. Dandy
我想把NET
+ VAT
和cell.address
分别在Customer面前的Summary列中进行汇总。
示例:摘要列
R S T
1. Customer T5NET T5VAT
2. Sandy =C3+C5 =D3+D5
3. etc
我假设我需要一个Match
函数来匹配#1 Customer
(摘要到数据库)和#2 T5
,然后连接针对汇总名称的偏移值。
编辑现在(这是接近,但我如何改变它的匹配功能?)
`Sub MatchConcanate()
Dim outputText As String, Rw As Range, cell As Range
delim = "+"
Application.ScreenUpdating = False
Range("A:A").SpecialCells(xlCellTypeConstants).Select
For Each Rw In Selection.Columns
'Here I want it to only Select Supplier till it is duplicate (they are sorted) and then to next
For Each cell In Rw.Cells
If cell.Value = "T5" Then
outputText = outputText & delim & cell.Address
End If
Next cell
With Rw
'Here I'd like a match function instead of pasting it all in cell 1
.Cells(1).Offset(0, 5).Value = outputText
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
End With
outputText = ""
Next Rw
Application.ScreenUpdating = True
End Sub`
将所有内容右移一列,并放入A1 "=B1 &C2"。例:客户和电汇
然后在列中使用sumif
Name T1 T2
Sandy =SUMIF(A:A,S2&$T$1,D:D) =SUMIF(A:A,S2&$U$1,D:D)
Candy =SUMIF(A:A,S3&$T$1,D:D) =SUMIF(A:A,S3&$U$1,D:D)
Dandy =SUMIF(A:A,S4&$T$1,D:D) =SUMIF(A:A,S4&$U$1,D:D)
由于新列"A"