使用this網站作爲源,我已經放在一起this工作簿提取並列出給定文件夾中的文件。VBA陰影交替行
的代碼工作正常,但我想通過在陰影列中的交替行,以適應這一點了C,d和E
我研究這一點,並找到了一個例子here
我得到的問題是,我只能設置陰影列E
,我不知道爲什麼。我也想遮擋另一排,但我有點不確定如何去做。
這是提取文件和遮蔽行的代碼。
Public Sub ListFilesInFolder(SourceFolder As Scripting.folder, IncludeSubfolders As Boolean)
Dim lngLastRow As Long
On Error Resume Next
For Each FileItem In SourceFolder.Files
' display file properties
Cells(iRow, 3).Formula = iRow - 13
Cells(iRow, 4).Formula = FileItem.Name
Cells(iRow, 5).Select
Selection.Hyperlinks.Add Anchor:=Selection, Address:= _
FileItem.Path, TextToDisplay:="Click Here to Open"
iRow = iRow + 1 ' next row number
lngLastRow = Sh.Cells(Cells.Rows.Count, "C").End(xlUp).Row
Range("C14:E" & lngLastRow).Activate
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(ROW(),2)=0"
Selection.FormatConditions(1).Interior.ColorIndex = 24
Next FileItem
If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFilesInFolder SubFolder, True
Next SubFolder
End If
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
End Sub
我只是想知道是否有人能夠看到這個請讓我知道我出了什麼問題。
不是每個人都可以從訪問Dropbox的自己工作環境,當你的問題得到解答時,你可能會/從這裏刪除文件。您最好在問題中發佈相關代碼,以提供我們在SO尋找的持久相關性。在編輯後進行評論的經典案例... – FreeMan 2015-04-06 14:41:32