LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default sub directories again

Unfortunately The VBA code didn't work...because there was a small command
error with this line:

If UCase(Right(MyName), 4) = UCase(MyCond) Then

I think we are not allowed to use anything else then just a string within
the "( )" for the UCase( xxxxxx) command.

Thus I changed your code a bit and now it works just fine...
Here goes:
--------------------------------
Sub ListFileName()

Dim filearray()
Dim MyPath, MyName, Mt, MyCond ' I declare an additional variable called
Mt
Dim j As Long, a As Long

MyPath = "c:\windows\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrive the first entry.
MyCond = ".txt"
Do While MyName < "" ' Start the loop.
If (GetAttr(MyPath & MyName) And vbDirectory) < vbDirectory Then
Mt = (Right(MyName, 4)) ' I use this new variable to get the last
four characters.
If UCase(Mt) = UCase(MyCond) Then ' And changed this bit such that
the format of UCase is accepted.
a = a + 1
ReDim Preserve filearray(a)
filearray(a) = MyName
End If
End If
MyName = Dir ' Get next entry.
Loop

Open "c:\filearray.txt" For Output As #1
For j = 1 To a
Write #1, filearray(j)
Next
Close #1

End Sub
---------------------------------------
Thanks a lot for your help.
Sincerely



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating directories freekrill Excel Discussion (Misc queries) 1 July 25th 05 09:26 AM
sub directories again Mike[_67_] Excel Programming 2 February 7th 04 12:06 AM
sub directories Mike Excel Programming 5 February 6th 04 10:15 PM
Directories Jeff[_24_] Excel Programming 4 January 20th 04 09:26 AM
Searching directories... Phobos Excel Programming 0 August 1st 03 12:03 AM


All times are GMT +1. The time now is 08:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"