Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default File Name Select Case

Hi,

I am searching for files on certain folder, and then, depending on the
filename, I want the code to do something specific for these files.
I am using a File Name Select Case which is not working. All files should
fall into one of the 3 categories of the select case, but they are not.

This is my code:

Sub FilesUpdate ()

Dim FName As String
Dim Path As String

Path = "C:\Pricing\Product1\1st May 2007"

With Application.FileSearch
.NewSearch
.LookIn = Path
.FileName = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count
FName = .FoundFiles(i)

Select Case FName

Case "*GC*"
UpdateGCFiles

Case "*PL*"
UpdatePLFiles

Case "*VC*"
UpdateVCFiles

End Select
Next
End With
End Sub

Any suggestions will be highly appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default File Name Select Case

Hi Corey,

Try something like:

'=============
Public Sub FilesUpdate()
Dim Fname As String
Dim Path As String

Path = "C:\Pricing\Product1\1st May 2007"

With Application.FileSearch
.NewSearch
.LookIn = Path
.Filename = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count
Fname = .FoundFiles(i)
Select Case True
Case UCase(Fname) Like "*GC*"
UpdateGCFiles
Case UCase(Fname) Like "*PL*"
UpdatePLFiles
Case UCase(Fname) Like "*VC*"
UpdateVCFiles
End Select
Next i
End With
End Sub
'<<=============


BTW, the FileSearch property has often been
reported as problematic and, indeed, has been
dropped fron XL2007. Perhaps, therefore,
consider using Dir function,

---
Regards,
Norman


"Cavy" wrote in message
...
Hi,

I am searching for files on certain folder, and then, depending on the
filename, I want the code to do something specific for these files.
I am using a File Name Select Case which is not working. All files should
fall into one of the 3 categories of the select case, but they are not.

This is my code:

Sub FilesUpdate ()

Dim FName As String
Dim Path As String

Path = "C:\Pricing\Product1\1st May 2007"

With Application.FileSearch
.NewSearch
.LookIn = Path
.FileName = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count
FName = .FoundFiles(i)

Select Case FName

Case "*GC*"
UpdateGCFiles

Case "*PL*"
UpdatePLFiles

Case "*VC*"
UpdateVCFiles

End Select
Next
End With
End Sub

Any suggestions will be highly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default File Name Select Case

Hi Corey,

Apologies; s/be:

Hi Cavy,


---
Regards,
Norman


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default File Name Select Case

Excellent!!!

Thank you very much Norman.


"Norman Jones" wrote:

Hi Corey,


Apologies; s/be:

Hi Cavy,


---
Regards,
Norman



Reply
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
select case Hein Excel Discussion (Misc queries) 5 November 24th 09 01:19 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
Select Case help Ramthebuffs[_14_] Excel Programming 4 October 13th 05 12:41 AM


All times are GMT +1. The time now is 02:03 PM.

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"