LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default fname = Dir() returns and 'invalid procedure call or argument'

I'm trying to verify filenames using the FName = Dir(nnn), but I prefer not
to open the files because it takes a long time across the network...

For a little background - the data conversions occur periodically, but they
are so 'involved' that they are not on a schedule, so the filenames have the
date included, but it could be 5 days or 20 days - and not something that I
can rely on in the code. So - I'm able to find out which "run" this is from
my workbook - if column r is blank, then I'm at run 13, etc.. - but there are
lots and lots of files in the folder, so I need to use a Dir("filename*.xls),
and then count those files - picking the 13th file (in this case).

Here is the code that I'm using. The FName = Dir() at the bottom is the one
that returns the error... There's a big section of code after "Else" (which
is irrelavent to this) that goes and gets the data, but I didn't want to
leave anything out...

Any suggestions?

Thanks!
John

cnt = 0
MyColumn1 = "D"
MyColumn2 = "H"
fName = Dir("\\mw\data\SMP-IT\Acceleration_Project\JDA_Docs\Johns Conversion
Metrics\ANA\Johns Conversion Load Metric ANA*.xls")
Do While fName < ""
If FileExists(fName) = True Then
cnt = cnt + 1
End If
If cnt < ANA_Cnt Then
cnt = cnt + 1
Else
Set MyRange = Range("A12:A100")
For Each c In MyRange
If c.Value = "IDF" Then
MyRow = c.Row
Range(MyColumn2 & Trim(Str(MyRow))).Select
IDF_Value = Selection.Value
Range(MyColumn1 & Trim(Str(MyRow))).Select
IDF_Value = 1 - (IDF_Value / Selection.Value)
ElseIf c.Value = "IM" Then
MyRow = c.Row
Range(MyColumn2 & Trim(Str(MyRow))).Select
IM_Value = Selection.Value
Range(MyColumn1 & Trim(Str(MyRow))).Select
IM_Value = 1 - (IM_Value / Selection.Value)
ElseIf c.Value = "ORD" Then
MyRow = c.Row
Range(MyColumn2 & Trim(Str(MyRow))).Select
ORD_Value = Selection.Value
Range(MyColumn1 & Trim(Str(MyRow))).Select
ORD_Value = 1 - (ORD_Value / Selection.Value)
ElseIf c.Value = "PID" Then
MyRow = c.Row
Range(MyColumn2 & Trim(Str(MyRow))).Select
PID_Value = Selection.Value
Range(MyColumn1 & Trim(Str(MyRow))).Select
PID_Value = 1 - (PID_Value / Selection.Value)
ElseIf c.Value = "PSF" Then
MyRow = c.Row
Range(MyColumn2 & Trim(Str(MyRow))).Select
PSF_Value = Selection.Value
Range(MyColumn1 & Trim(Str(MyRow))).Select
PSF_Value = 1 - (PSF_Value / Selection.Value)
End If
Next
End If

fName = Dir()

Loop

Again - thanks!
JB
 
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
CreatePivotTable: Invalid procedure call or argument DesertCyclist Excel Programming 4 October 15th 10 03:53 PM
Invalid procedure call or argument for Dir$ (Run-time error '5') ? Alan[_8_] Excel Programming 0 July 21st 08 03:14 PM
Invalid Procedure Call Or Argument with VBScript [email protected] Excel Programming 0 November 28th 07 01:50 PM
Invalid procedure call or argument error Patrick Simonds Excel Programming 1 August 12th 06 11:40 PM
Invalid Procedure call or argument T De Villiers[_58_] Excel Programming 1 July 25th 06 03:01 PM


All times are GMT +1. The time now is 01:16 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"