- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æµ²ªG:
Option Explicit
Sub TEST_2()
Dim Brr, Crr, Y, TT, R&, C&, R1&, C1&, i&, Vb&, Ve&, Tc$, Td$, Ta$
Dim xR1 As Range, Sh1 As Worksheet
Set Y = CreateObject("Scripting.Dictionary")
Set Sh1 = Sheets("Sheet1")
Set xR1 = Range(Sh1.[E1], Sh1.Cells(Rows.Count, "A").End(xlUp)): Brr = xR1
For i = 2 To UBound(Brr)
Ta = Brr(i, 1): Tc = Brr(i, 3): Td = Brr(i, 4)
Vb = Val(Brr(i, 2)): Ve = Val(Brr(i, 5))
If Td = "" Or Ta = "" Or Td = "" Then GoTo i01
TT = Td & "|" & Ta & "|" & Tc
If Y(Td & "|" & Ta) = "" Then
R = R + 1: R1 = R: Y(Td & "|" & Ta) = R1
Else
R1 = Y(Td & "|" & Ta)
End If
If Y(Tc) = "" Then
C = C + 1: C1 = C: Y(Tc) = C1
Else
C1 = Y(Tc)
End If
Y(TT & "|r") = R1: Y(TT & "|c") = C1
If Ve > Val(Y(TT)) Then: Y(TT) = Ve & "^0*" & Vb
i01: Next
ReDim Crr(1 To Y.Count, 1 To Columns.Count)
For Each TT In Y.keys
If InStr(Y(TT), "^") Then
Crr(Y(TT & "|r") + 2, Y(TT & "|c") + 2) = Evaluate(Y(TT))
ElseIf TT Like "*|*|*" = False And TT Like "*|*" Then
Crr(Y(TT) + 2, 1) = Split(TT, "|")(0)
Crr(Y(TT) + 2, 2) = Split(TT, "|")(1)
ElseIf InStr(TT, "|") = 0 Then
Crr(2, Y(TT) + 2) = TT
End If
i00: Next
Crr(1, 1) = "Group2": Crr(1, 2) = "LocnID": Crr(1, 3) = "TenderID"
Workbooks.Add
[A1].Resize(R + 2, C + 2) = Crr
[A1].Item(1, 3).Resize(1, C).Merge
[A1].Item(1, 3).HorizontalAlignment = xlCenter
Set Y = Nothing: Set Sh1 = Nothing: Set xR1 = Nothing: Erase Brr, Crr
End Sub |
|