Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Edit message of a file search to a Cell

Hi,

I try to establish if certain file names are present on a
certain location and if they are I would like this to be
entered in the next column.

What I have so far to identify if a file exist is a bit
of a workaround.

Sub Start()
Dim rngStartPoint As Range
Range("A1").Activate
Set rngStartPoint = ActiveCell
Do
If ActiveCell.Offset(1, 1) = "" Then
Exit Do
ElseIf ActiveCell.Offset(1, 0) < "" Then
Else
Call File_Search
End If
ActiveCell.Offset(1, 0).Activate
Loop
rngStartPoint.Activate
End Sub

Sub File_Search()
Set fs = Application.FileSearch
With fs
.NewSearch
.LookIn = "X:\"
.SearchSubFolders = True
.Filename = ActiveCell
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub

it only works with spacings between all the cells and the
column to the right needs to be filled (changing this
would also be nice).

Requested ouptut:
'Name 'Result
File1a.xxx Y
File1b.xxx N

Thanks in advance,
Hans Weustink

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Edit message of a file search to a Cell

Assume you have a list of file names in Column A starting in A2 and you want
to put a Y in column B of that row for those files found in the directory
C:\Myfolder or a "N" if not found.

Sub Start()
Range("A2").Activate
chDrive "C"
chDir "C:\MyFolder"
Do
if ActiveCell.offset(0,1) = "" then
if Dir(ActiveCell.Value) < "" then
ActiveCell.Offset(0,1) = "Y"
else
ActiveCell.Offset(0,1) = "N"
end if
End if
ActiveCell.offset(1,0).Select
Loop while ActiveCell.Value < ""
Range("A1").Select
End Sub

--
Regards,
Tom Ogilvy





"Hans Weustink" wrote in message
...
Hi,

I try to establish if certain file names are present on a
certain location and if they are I would like this to be
entered in the next column.

What I have so far to identify if a file exist is a bit
of a workaround.

Sub Start()
Dim rngStartPoint As Range
Range("A1").Activate
Set rngStartPoint = ActiveCell
Do
If ActiveCell.Offset(1, 1) = "" Then
Exit Do
ElseIf ActiveCell.Offset(1, 0) < "" Then
Else
Call File_Search
End If
ActiveCell.Offset(1, 0).Activate
Loop
rngStartPoint.Activate
End Sub

Sub File_Search()
Set fs = Application.FileSearch
With fs
.NewSearch
.LookIn = "X:\"
.SearchSubFolders = True
.Filename = ActiveCell
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub

it only works with spacings between all the cells and the
column to the right needs to be filled (changing this
would also be nice).

Requested ouptut:
'Name 'Result
File1a.xxx Y
File1b.xxx N

Thanks in advance,
Hans Weustink



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
show a customised message when a trying to edit a locked cell Emily Ladywell Excel Worksheet Functions 1 May 21st 09 06:03 PM
How can I search Excel database and edit an entry? saziz Excel Discussion (Misc queries) 1 February 8th 06 08:30 PM
Search & Edit in Excel Database possible? saziz Excel Discussion (Misc queries) 3 February 2nd 06 09:47 PM
File won't open. Error message "too many different cell formats" baytulsa Excel Worksheet Functions 1 September 12th 05 07:21 PM
I have opened an Excel file and I can't edit any cell Elise0 New Users to Excel 2 March 1st 05 08:51 AM


All times are GMT +1. The time now is 03:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"