我需要合并具有匹配数据的行。 我的标准是,如果我的列销售订单具有相同的值,则应合并与该销售订单相关的所有采购订单值
之前
后
我试过这个
Sub Test()
Dim c As Long, stDesc As String, stType As String, dt As Date
Dim Withdrawn As Double, dPaidIn As Double, dBal As Double
c = 1
Do While Range("A2").Cells(c, 1) <> ""
If Range("A2").Cells(c, 1) > 0 Then
dt = Range("A2").Cells(c, 1)
' dt = Range("A2").Cells(c, 1)
stType = Range("B2").Cells(c, 1)
Do
stDesc = stDesc & " " & Range("C2").Cells(c, 1)
c = c + 1
Loop Until Range("A2").Cells(c, 1) <> ""
Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = dt
Range("A" & Rows.Count).End(xlUp).Offset(0, 1) = stType
Range("A" & Rows.Count).End(xlUp).Offset(0, 2) = stDesc
Range("A" & Rows.Count).End(xlUp).Offset(0, 3) = Range("A2").Cells(c - 1, 4)
Range("A" & Rows.Count).End(xlUp).Offset(0, 4) = Range("A2").Cells(c - 1, 5)
Range("A" & Rows.Count).End(xlUp).Offset(0, 5) = Range("A2").Cells(c - 1, 6)
End If
stDesc = ""
Loop
End Sub