【发布时间】:2019-09-26 20:57:25
【问题描述】:
我需要帮助。我需要删除文件夹中的旧文件。我在 B 列中有一个文件列表,旧文件的颜色为 RGB(255,0,0)。假设代码如下所示:
Dim MyFolder As String
Dim MyFile As String
Dim cell As Variant
Dim source As Range
Set source = Range("c3:c8")
MyFolder = Sheets("Delete Revs").Range("K1").Value & "\"
MyFile = Dir(MyFolder & "\" & "*.*")
For Each cell In source
If cell.Interior.Color = RGB(255, 0, 0) Then
Kill MyFile
Else
End If
Next
【问题讨论】:
-
到底是什么问题?
-
If Cell.Interior.Color = vbRed Then: Kill Cell.Value等 -
我不知道如何编写代码。我还是新手,我找不到我想做的例子。
-
我刚试过这段代码。 “修改了原文”
-
Read This。有大量免费的 VBA 教程可帮助您开始正确编写代码。
标签: excel vba for-loop delete-file