I have a VBA to list all files from a folder.
How to I select only excel file from a folder? Help Please?
VBA:
Sub InsertFilesInFolder()
Dim sPath As String, Value As String
Dim WS As Worksheet
Set WS = Sheets.Add
sPath = ActiveWorkbook.Path & "\"
Value = Dir(sPath, &H1F)
WS.Range("A1") = "Filename"
Set StartCell = WS.Range("A2")
Do Until Value = ""
If Value = "." Or Value = ".." Then
Else
If GetAttr(sPath & Value) = 16 Then
Else
If Value <> ActiveWorkbook.Name And Value <> "~$" & ActiveWorkbook.Name Then
StartCell.Hyperlinks.Add Anchor:=StartCell, Address:= _
Value, TextToDisplay:=Value
Set StartCell = StartCell.Offset(1, 0)
End If
End If
End If
Value = Dir
Loop
End Sub
How to I select only excel file from a folder? Help Please?
VBA:
Sub InsertFilesInFolder()
Dim sPath As String, Value As String
Dim WS As Worksheet
Set WS = Sheets.Add
sPath = ActiveWorkbook.Path & "\"
Value = Dir(sPath, &H1F)
WS.Range("A1") = "Filename"
Set StartCell = WS.Range("A2")
Do Until Value = ""
If Value = "." Or Value = ".." Then
Else
If GetAttr(sPath & Value) = 16 Then
Else
If Value <> ActiveWorkbook.Name And Value <> "~$" & ActiveWorkbook.Name Then
StartCell.Hyperlinks.Add Anchor:=StartCell, Address:= _
Value, TextToDisplay:=Value
Set StartCell = StartCell.Offset(1, 0)
End If
End If
End If
Value = Dir
Loop
End Sub