PDA

View Full Version : Solved: Correct File Selected



av8tordude
02-04-2012, 06:38 AM
MyFolder\Domestic\2012.xls

In the above path, how can I make sure the file name (2012.xls) matches the name in range A1? I'm not concerned about the folder or location, just the file name.

Thanks for your assistance.

xld
02-04-2012, 07:16 AM
Dim filename As String
Dim fileparts As Variant

filename = "MyFolder\Domestic\2012.xls"
fileparts = Split(filename, Application.PathSeparator)
If fileparts(UBound(fileparts)) = Range("A1").Value Then

'do stuff

av8tordude
02-04-2012, 09:01 AM
Thank you XLD