I use this to create a list in Column B of my sheet. I would like to be able to change this to add the list starting at the bottom, so I can leave the existing data alone. This will create duplicates. I want the duplicates at the bottom removed leaving only NEW names.
I am a novice with VBA. I would appreciate some help.
Thanks!
Sub ListSubFolders()
'macro to pull folder names into the column
Dim Cell As Range
Dim Folder As Variant
Dim SubFolders As Variant
Dim vArray As Variant
Set Cell = Range("B3")
Folder = "R:\Bids\" & [C1]
With CreateObject("Shell.Application")
Set SubFolders = .Namespace(Folder).Items
SubFolders.Filter 32, "*"
End With
If SubFolders.Count = 0 Then
MsgBox "There are No Subfolders in this Directory."
Exit Sub
End If
ReDim vArray(1 To SubFolders.Count, 1 To 1)
For n = 0 To SubFolders.Count - 1
vArray(n + 1, 1) = SubFolders.Item(n).Name
Next n
With Cell.Resize(n, 1)
.NumberFormat = "@"
.Value = vArray
End With
Range("B3").Select
End Sub