|
楼主 |
发表于 2022-12-23 21:13
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub tDel()
- Dim Dict As Dictionary, Dict1 As Dictionary
- Set Dict = New Dictionary
- Set Dict1 = New Dictionary
- Dim Rng As Range, oRng As Range, Arr
- Dim Str
- Set Rng = Selection
- For Each oRng In Rng
- Str = Evaluate("CELL(""format""," & oRng.Address & ")")
- If Str = "D9" Then
- 'Debug.Print Format(oRng, "hh:mm:ss"), Str, oRng.Address
- Set Dict(oRng.Value) = oRng
- ElseIf Str = "G" Then
- Set Dict(oRng.Value) = oRng
- End If
- Next oRng
- For ii = 0 To Dict.Count - 1
- Debug.Print Dict.Keys(ii), Dict.Items(ii).Address
- Next ii
- Arr = DictionarySort(Dict)
- For ii = 0 To UBound(Arr)
- For kk = 0 To Dict.Count - 1
- If Dict.Keys(kk) = Arr(ii) Then
- Set oRng = Dict.Items(kk)
- Debug.Print Dict.Keys(kk), oRng.Address
- Set Dict1(Dict.Keys(kk)) = oRng
- End If
- Next kk
- Next ii
- Stop
- For ii = 0 To Dict1.Count - 1
- Debug.Print Dict1.Keys(ii), Dict1.Items(ii).Address
- Next ii
- End Sub
- Sub del()
- Dim Dict As Dictionary, Dict1 As Dictionary
- Set Dict = New Dictionary
- Set Dict1 = New Dictionary
- Dim Rng As Range, oRng As Range, Arr
- Dim Str
- Set Rng = Selection
- For Each oRng In Rng
- Str = Format(oRng.Value, "hh:mm:ss")
- If IsDate(Str) Then
- Dict(Str) = ""
- Else
- Str = Val(oRng.Value)
- Dict(Str) = ""
- End If
-
- Next oRng
- Stop
- End Sub
- Function DictionarySort(Dict As Dictionary)
- ''
- Dim ii, jj, Tmp
- Dim Num1, Num2
- Dim Arr
- With Dict
- Arr = .Keys
- ''
- For ii = 1 To .Count '- 1
- For jj = 1 To .Count '- 1
- Num1 = Val(Arr(ii - 1))
- Num2 = Val(Arr(jj - 1))
- ''
- If Num1 > Num2 Then
- Tmp = Arr(ii - 1)
- 'Debug.Print Arr(ii - 1), Arr(jj - 1)
- Arr(ii - 1) = Arr(jj - 1)
- Arr(jj - 1) = Tmp
- End If
- Next jj
- Next ii
- End With
- DictionarySort = Arr
- End Function
复制代码 If Str = "D9" Then
'Debug.Print Format(oRng, "hh:mm:ss"), Str, oRng.Address
Set Dict(oRng.Value) = oRng
ElseIf Str = "G" Then
Set Dict(oRng.Value) = oRng
End If
If IsDate(Str) Then
Dict(Str) = ""
Else
Str = Val(oRng.Value)
Dict(Str) = ""
End If
|
|