|
准备工作已经做好,就是字典排序了。
- Sub del1()
- Dim Str
- Dim Dict As Dictionary, Dict1 As Dictionary
- Dim ii, jj
- Set Dict = New Dictionary
- Set Dict1 = New Dictionary
- Dim Rng As Range, Rng1 As Range, Rng2 As Range
- Dim Arr
- Dim mR As Range, tmpRng As Range, tmp1, tmp2
- With Sheet1
- Set Rng = .Range(.Cells(3, 2), .Cells(.Cells(56656, 1).End(xlUp).Row, "Q"))
- Set tmpRng = .Cells(1, "X")
- End With
- ''
- For Each mR In Rng
- tmp1 = mR
- If Val(tmp1) > Val(tmp2) Then
- Set tmpRng = mR
- tmp2 = tmp1
- End If
- Next mR
- 'Debug.Print tmpRng.Value, tmpRng.Address
- For ii = 1 To Rng.Rows.Count
- Str = Rng(ii, 0)
- ''
- If IsDate(Str) Then
- For jj = 2 To Rng.Columns.Count Step 2
- Set Dict(Rng(ii, jj)) = Rng(ii, 0)
- Next jj
- End If
- Next ii
- ''
- For ii = 0 To Dict.Count - 1
- 'Debug.Print Dict.Items(ii).Address, Dict.Keys(ii).Address & "---",
- With Dict
- Set Rng1 = .Items(ii)
- Set Rng2 = .Keys(ii)
- 'Dict1(.Items(ii)) = .Keys(ii)
- End With
- ''
- Set Dict1(Rng1) = Rng2
- ''
- Debug.Print Dict1.Items(ii), Dict1.Keys(ii),
- Debug.Print Dict1.Items(ii).Address, Dict1.Keys(ii).Address
- Next ii
- Stop
- End Sub
复制代码
|
|