RB,
Thank you for your help! For function works great ! Would you mind to
briefly explain how does the fifth line work ["bFileExists = (Err.Number = 0)
And ((lAttr And vbDirectory) = 0)"]. I'm new to creating custom functions and
am trying to learn as much as possible.
Thanks a lot!
Magnivy
"RB Smissaert" wrote:
Even better:
Function bFileExists(ByVal sFile As String) As Boolean
Dim lAttr As Long
On Error Resume Next
lAttr = GetAttr(sFile)
bFileExists = (Err.Number = 0) And ((lAttr And vbDirectory) = 0)
On Error GoTo 0
End Function
RBS
"Chip Pearson" wrote in message
...
Better code:
Dim Rng As Range
For Each Rng In Range("A1:A10")
If Rng.Text < "" Then
If Dir(Rng.Text) < "" Then
' file exists
Else
' file doesn't exist
End If
End If
Next Rng
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Chip Pearson" wrote in message
...
Try something like
Dim Rng As Range
For Each Rng In Range("A1:A10")
If Dir(Rng.Text) < "" Then
' file exists
Else
' file doesn't exist
End If
Next Rng
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Magnivy" wrote in message
...
Greetings!
I have a macro that opens files for which the path is indicated in a
range,
say A1:A50. Before I run the macro, I would like to test whether the
file
paths are entered correctly. I'm trying to create a macro that would
test
whether the files contained in cells A1:A10 exist, but cant come up with
anything.
Any insight you provide would be greatly appreciated.
Sincerely,
Magnivy