Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default List out FileNames.xls with K4 Blank

I'm trying to edit some existing (similar) code that will
Search all files (all.xls) in a folder and list out on my current sheet from
A4 downward
all files where the search finds Cell "K4" in each file to be Blank.
Posting my code would be near useless.
I'm been to google and help and am now exhausted.. Can anyone assist?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default List out FileNames.xls with K4 Blank

Here's some code, but be aware that the workbook could contain many
worksheets. This code just looks at sheet 1

Sub ShowSomeFiles()
Dim i As Long, j As Long

Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\MyTest"
.Filename = ".xls"
.SearchSubFolders = False
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
If IsEmpty(ActiveWorkbook.Worksheets(1).Range("K4").V alue) Then
Range("A4").Offset(j, 0).Value = .FoundFiles(i)
j = j + 1
End If
ActiveWorkbook.Close savechanges:=False
Next i
End With
Application.ScreenUpdating = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JMay" wrote in message
news:Q3GAb.49607$yM6.26347@lakeread06...
I'm trying to edit some existing (similar) code that will
Search all files (all.xls) in a folder and list out on my current sheet

from
A4 downward
all files where the search finds Cell "K4" in each file to be Blank.
Posting my code would be near useless.
I'm been to google and help and am now exhausted.. Can anyone assist?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default List out FileNames.xls with K4 Blank

Bob: Thanks for the code -- however purposely blanking out cell K4 in one
of my workbooks does not list that filename beginning in my A4 of my "home"
Worksheet. My A4 continues blank - should have one file
C:\My Documents\CMyGroup\4126Jan2003.xls, but doesn't.

This line (below) is suspect: Does the code know to write the value of
..FoundFiles(i) to my Originating Workbook and Worksheet (Sheet1) as this
line is within the loop?

Range("A4").Offset(j, 0).Value = .FoundFiles(i)

Any thoughts?
Thanks,
JMay


"Bob Phillips" wrote in message
...
Here's some code, but be aware that the workbook could contain many
worksheets. This code just looks at sheet 1

Sub ShowSomeFiles()
Dim i As Long, j As Long

Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\MyTest"
.Filename = ".xls"
.SearchSubFolders = False
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
If IsEmpty(ActiveWorkbook.Worksheets(1).Range("K4").V alue)

Then
Range("A4").Offset(j, 0).Value = .FoundFiles(i)
j = j + 1
End If
ActiveWorkbook.Close savechanges:=False
Next i
End With
Application.ScreenUpdating = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JMay" wrote in message
news:Q3GAb.49607$yM6.26347@lakeread06...
I'm trying to edit some existing (similar) code that will
Search all files (all.xls) in a folder and list out on my current sheet

from
A4 downward
all files where the search finds Cell "K4" in each file to be Blank.
Posting my code would be near useless.
I'm been to google and help and am now exhausted.. Can anyone assist?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default List out FileNames.xls with K4 Blank

Not really sure what the problem is. The code I supplied lists all files, by
name, with cell K4 in worksheet 1 as a blank cell.

The line you highlight is the line that outputs the filename to your home
worksheet. It is assuming that you start with your home worksheet open.

You could try replacing that line with this to be more precise

ThisWorkbook.Worksheets(1).Range("A4").Offset(j, 0).Value =
..FoundFiles(i)

In my test I had 9 files that were empty and 1 that wasn't, and I got a list
of the 9.

The other thin to be aware of is that it is checking for empty, so spaces
are treated as a value.

Try it and post back.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JMay" wrote in message
news:XNHAb.50065$yM6.13569@lakeread06...
Bob: Thanks for the code -- however purposely blanking out cell K4 in one
of my workbooks does not list that filename beginning in my A4 of my

"home"
Worksheet. My A4 continues blank - should have one file
C:\My Documents\CMyGroup\4126Jan2003.xls, but doesn't.

This line (below) is suspect: Does the code know to write the value of
.FoundFiles(i) to my Originating Workbook and Worksheet (Sheet1) as this
line is within the loop?

Range("A4").Offset(j, 0).Value = .FoundFiles(i)

Any thoughts?
Thanks,
JMay


"Bob Phillips" wrote in message
...
Here's some code, but be aware that the workbook could contain many
worksheets. This code just looks at sheet 1

Sub ShowSomeFiles()
Dim i As Long, j As Long

Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\MyTest"
.Filename = ".xls"
.SearchSubFolders = False
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
If IsEmpty(ActiveWorkbook.Worksheets(1).Range("K4").V alue)

Then
Range("A4").Offset(j, 0).Value = .FoundFiles(i)
j = j + 1
End If
ActiveWorkbook.Close savechanges:=False
Next i
End With
Application.ScreenUpdating = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JMay" wrote in message
news:Q3GAb.49607$yM6.26347@lakeread06...
I'm trying to edit some existing (similar) code that will
Search all files (all.xls) in a folder and list out on my current

sheet
from
A4 downward
all files where the search finds Cell "K4" in each file to be Blank.
Posting my code would be near useless.
I'm been to google and help and am now exhausted.. Can anyone assist?








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default List out FileNames.xls with K4 Blank

That did the trick Bob;
Works great!!
Tks again,
JMay

"Bob Phillips" wrote in message
...
Not really sure what the problem is. The code I supplied lists all files,

by
name, with cell K4 in worksheet 1 as a blank cell.

The line you highlight is the line that outputs the filename to your home
worksheet. It is assuming that you start with your home worksheet open.

You could try replacing that line with this to be more precise

ThisWorkbook.Worksheets(1).Range("A4").Offset(j, 0).Value

=
.FoundFiles(i)

In my test I had 9 files that were empty and 1 that wasn't, and I got a

list
of the 9.

The other thin to be aware of is that it is checking for empty, so spaces
are treated as a value.

Try it and post back.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JMay" wrote in message
news:XNHAb.50065$yM6.13569@lakeread06...
Bob: Thanks for the code -- however purposely blanking out cell K4 in

one
of my workbooks does not list that filename beginning in my A4 of my

"home"
Worksheet. My A4 continues blank - should have one file
C:\My Documents\CMyGroup\4126Jan2003.xls, but doesn't.

This line (below) is suspect: Does the code know to write the value of
.FoundFiles(i) to my Originating Workbook and Worksheet (Sheet1) as this
line is within the loop?

Range("A4").Offset(j, 0).Value = .FoundFiles(i)

Any thoughts?
Thanks,
JMay


"Bob Phillips" wrote in message
...
Here's some code, but be aware that the workbook could contain many
worksheets. This code just looks at sheet 1

Sub ShowSomeFiles()
Dim i As Long, j As Long

Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\MyTest"
.Filename = ".xls"
.SearchSubFolders = False
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
If IsEmpty(ActiveWorkbook.Worksheets(1).Range("K4").V alue)

Then
Range("A4").Offset(j, 0).Value = .FoundFiles(i)
j = j + 1
End If
ActiveWorkbook.Close savechanges:=False
Next i
End With
Application.ScreenUpdating = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JMay" wrote in message
news:Q3GAb.49607$yM6.26347@lakeread06...
I'm trying to edit some existing (similar) code that will
Search all files (all.xls) in a folder and list out on my current

sheet
from
A4 downward
all files where the search finds Cell "K4" in each file to be Blank.
Posting my code would be near useless.
I'm been to google and help and am now exhausted.. Can anyone

assist?










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
Indirect validation list with blank in list RT Excel Discussion (Misc queries) 3 June 5th 09 02:36 AM
can not scroll on Edit links very long list of filenames Louw Rademeyer SARS Excel Discussion (Misc queries) 1 March 19th 09 12:48 PM
drop down list shows first blank row after last list entry Jerry Bennett[_2_] Excel Discussion (Misc queries) 1 November 10th 07 11:35 AM
Eliminate Blank Rown in a List - Then Create New List geither Excel Discussion (Misc queries) 1 December 14th 06 07:51 PM
List all filenames & tab names Deeds Excel Worksheet Functions 5 May 18th 06 11:16 PM


All times are GMT +1. The time now is 10:31 PM.

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"