View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bishop Bishop is offline
external usenet poster
 
Posts: 208
Default Selecting a specific file from many

Ok, nevermind... apparently the correct workbook wasn't active... which is
odd really. The active workbook should have been Monthly Compiler. My plan
is to assign this macro to a button in that workbook. So if I run the macro
from a button in the Monthly Compiler workbook is there any reason I should
have to put a line of code in the macro that makes sure Monthly Compiler is
the active workbook before it runs?

"Bishop" wrote:

I did what you asked. This is what's happening now:

"X:\C&A Analysts Team\PF Process\1 Tally & PF's Work in
Progress\Centers\Bardstown\* *.xl*"

So it looks like CMonth and CYear aren't showing up for some reason. I added:

Dim MonthFilter As String

And I have the following code:

CMonth = Left(Cells(13, 4).Value, 3)
CYear = Right(Cells(13, 7).Value, 2)

MyPath = "X:\C&A Analysts Team\PF Process\1 Tally & PF's Work in
Progress\Centers\"

MonthFilter = MyPath & center(i) & "\*" & CMonth & " " & CYear &
"*.xl*"
FilesInPath = Dir(MonthFilter)

What I need is:

"X:\C&A Analysts Team\PF Process\1 Tally & PF's Work in
Progress\Centers\Bardstown\* Aug 09 *.xl*"

"OssieMac" wrote:

Hi Bishop,

I think you are missing a space between cmonth and cyear in the concatenated
string.
Try creating the concatenated string in a string variable and then place a
stop in the code after the concatenation and when the code stops, select
debug and hover the cursor over the variable and see what it is returning.

myFilter = MyPath & center(i) & "\*" & CMonth & " " & CYear & "*.xl*"
Stop
FilesInPath = Dir(myFilter)

--
Regards,

OssieMac