Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA to find Cell Range in Files in Folder, return value

A specific workbook or are you talking about opening all workbooks and
looking for the value. If the latter, you should be able to modify the code
you already have. Again, you have talked about a cell address in a
workbook, but haven't said what sheet to look on.

--
Regards,
Tom Ogilvy


"JavyD" wrote in message
...
Hello guys,

Is it possible to create a VBA for my existing file, look at the Target in
say CEll A1, then look into work books in a folder, find that Target in a
work book, and bring back a value that would be in cell B25? Is this
possible?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA to find Cell Range in Files in Folder, return value

Sub Quote()
Dim mybook As Workbook
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String
Dim sTarget as String
Dim rng as Range
Dim sh as worksheet
set sh = Workbooks("June.xls").Worksheets(1)
sTarget = sh.Range("A1").Value
SaveDriveDir = CurDir
MyPath = "C:\Documents and Settings\Javier\My Documents\Test\"
ChDrive MyPath
ChDir MyPath
FNames = Dir("*.xls")
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If

Application.ScreenUpdating = False
Do While FNames < ""
Set mybook = Workbooks.Open(Filename:=FNames, _
UpdateLinks:=0)
set rng = myBook.Worksheets(1).Cells.Find(sTarget)
if not rng is nothing then
sh.Range("B1").Value = rng.Parent.Range("B25").Value
mybook.close SaveChanges:=False
exit do
end if

mybook.Close False
FNames = Dir()
Loop
ChDrive SaveDriveDir
ChDir SaveDriveDir
Application.ScreenUpdating = True
End Sub

--
Regards,
Tom Ogilvy

"JavyD" wrote in message
...
Hey Tom, long time no see. LOL. No specific file, all .xls in a folder,

say
my docs. But this time, I want it to target a specific value. Say I want
the VBA to look at my file, say June. I want it to see A1 in June Sheet

1,
look at its value, look for that value in a folder in all xls, once it

finds
a work book with sheet 1 with that value, which always is in the same

range
if that helps, I want it to bring back a value that is in another range in
the found work book, and imported back to cell B1 in June

"Tom Ogilvy" wrote:

A specific workbook or are you talking about opening all workbooks and
looking for the value. If the latter, you should be able to modify the

code
you already have. Again, you have talked about a cell address in a
workbook, but haven't said what sheet to look on.

--
Regards,
Tom Ogilvy


"JavyD" wrote in message
...
Hello guys,

Is it possible to create a VBA for my existing file, look at the

Target in
say CEll A1, then look into work books in a folder, find that Target

in a
work book, and bring back a value that would be in cell B25? Is this
possible?






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
Find data in Range, Return Cell Reference Hugh Excel Discussion (Misc queries) 7 April 16th 09 04:22 PM
How to find all folder and/or files in a specific location Mr. GetRight Excel Discussion (Misc queries) 0 July 2nd 08 06:51 PM
find the first blank cell in a range and return me it's position steve alcock Links and Linking in Excel 2 May 13th 05 09:03 AM
Copy several range from all files in folder into several worksheets Adri[_2_] Excel Programming 13 June 27th 04 03:52 PM
how to step thru only one subfolder of a folder to find like files foamfollower Excel Programming 1 November 11th 03 08:40 PM


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