|
本帖最后由 ning84 于 2024-8-20 23:42 编辑
- Sub ll()
- Dim Rng As Range
- Set Rng = Selection
- Rng.EntireRow.Interior.ColorIndex = 4
- Stop
- Rng.EntireRow.Delete
- End Sub
复制代码
Rng.EntireRow.Select就乱套了。
- Sub SelectMergeFileDeleteRng()
- Dim Str, ii, jj, kk
- Dim Rng As Range, oRng As Range, Rng1 As Range, Rng2 As Range
- Dim Fso As FileSystemObject, oFile As File
- Set Fso = New FileSystemObject
- Dim Sht As Worksheet
- Set Rng = Selection
- Debug.Print Rng.Address
- Set Sht = Rng.Parent
- Set oRng = Sht.Cells(Rng.Row, "F").Resize(Rng.Rows.Count, 1)
- Debug.Print oRng.Address
- Rng = "=count(" & oRng.Address & ")"
- Stop
- Dim oFolder As Folder, PathName
- With Sht
- For ii = Rng.Rows.Count To 1 Step -1
- Debug.Print .Cells(Rng(ii, 1).Row, "D").Address
- Str = .Cells(Rng(ii, 1).Row, "H")
- Set oRng = .Cells(Rng(ii, 1).Row, "D")
-
- If Fso.FileExists(Str) Then
- Set oFile = Fso.GetFile(Str)
-
- If .Cells(Rng(ii, 1).Row, "D") = oFile.Name Then
- oRng.Interior.ColorIndex = 3
- End If
- ElseIf Not Fso.FileExists(Str) Then
- oRng.EntireRow.Interior.ColorIndex = 4
- oRng.EntireRow.Delete
- End If
- Next ii
- End With
- ''
- End Sub
复制代码
|
|