Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Search and extract

Hi...

I have 200 identical files that contain data that I need to populate a
standalone table. I have been using the following code superbly well to
extract pinpoint data from targeted sheets.

Sub MakeLinksForGordon()
Dim myCell As Range

For Each myCell In Selection
myCell.Formula = _
"='" & Cells(myCell.Row, 1).Value & "\[" & _
Cells(myCell.Row, 2) & "]" & _
Cells(myCell.Row, 3) & "'!" & _
Cells(1, myCell.Column)
Next myCell
End Sub

However, the sheet name has now become variable as some of the files are no
longer identical. The above code now asks me which sheet I desire to search
when the expected sheet can't be found

What I need to happen is this:

In range b2:b200 I enter the path
In range c2:c200 I enter the file.xls
In cell c3 I enter the sheet name (sheet 1) that will apply to the code but
not the range, because not all of the files in the range will have sheet 1.

Basically what I enter in cell C3 will be the only sheet searched. If the
code comes across a file that doesn't have say sheet 1 then it skips it?

Sounds complex? It is...any help or alternative would be greatly appreciated.

Thanks

Gordon...
  #2   Report Post  
Posted to microsoft.public.excel.programming
mcg mcg is offline
external usenet poster
 
Posts: 18
Default Search and extract


Gordon napisal(a):
Hi...

I have 200 identical files that contain data that I need to populate a
standalone table. I have been using the following code superbly well to
extract pinpoint data from targeted sheets.

Sub MakeLinksForGordon()
Dim myCell As Range

For Each myCell In Selection
myCell.Formula = _
"='" & Cells(myCell.Row, 1).Value & "\[" & _
Cells(myCell.Row, 2) & "]" & _
Cells(myCell.Row, 3) & "'!" & _
Cells(1, myCell.Column)
Next myCell
End Sub

However, the sheet name has now become variable as some of the files are no
longer identical. The above code now asks me which sheet I desire to search
when the expected sheet can't be found

What I need to happen is this:

In range b2:b200 I enter the path
In range c2:c200 I enter the file.xls
In cell c3 I enter the sheet name (sheet 1) that will apply to the code but
not the range, because not all of the files in the range will have sheet 1.

Basically what I enter in cell C3 will be the only sheet searched. If the
code comes across a file that doesn't have say sheet 1 then it skips it?

Sounds complex? It is...any help or alternative would be greatly appreciated.

Thanks

Gordon...


put name of correct sheet in column D and

For i = 1 To 200
file = Cells(i, 2).Value & Cells(i, 3).Value
Sheet = Cells(i, 4).Value
Workbooks.Open Filename:=file
Sheets(Sheet).Range(your range). ' your action
.....
Next i

mcg

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
search or find, and extract? SusanInTexas Excel Discussion (Misc queries) 1 August 24th 07 10:20 PM
Search/Extract Formula M Moore Excel Discussion (Misc queries) 5 August 29th 06 04:28 AM
filename search and extract into a cell M John Excel Discussion (Misc queries) 5 April 28th 06 10:11 PM
Search & extract from multiple workbooks Ann Excel Programming 6 November 15th 05 08:34 PM
search and extract within text sunnyday Excel Programming 1 September 7th 05 02:44 AM


All times are GMT +1. The time now is 05:43 PM.

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"