Sub DoDir()
' Display the names in C:\ that represent directories.
myPath = "c:\" ' Set the path.
MyName = Dir(myPath, vbDirectory) ' Retrieve the first entry.
DirCount = 0
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If InStr(1, MyName, ".sys"

= 0 Then
theAttrib = GetAttr(myPath & MyName)
If (theAttrib And vbDirectory) = vbDirectory Then
ActiveCell.Offset(DirCount).Value = myPath & MyName
DirCount = DirCount + 1
End If ' it represents a directory.
End If
End If
MyName = Dir ' Get next entry.
Loop
End Sub