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

Hi.

I have a big problem and this might be a bridge too far for those that have
always come to my aid in the past.

The problem. I have @5000 Excel files that hold product details in a folder
called FILES. Each file is randomly titled. Each file is has been created
from a base template so they are all identical in format but different in
content. Each product is identified by a product number. However the product
number shares a cell with random text. eg. Green bananas pn 3378 and yellow
bananas pn 7765. What I need to do is run some excel code that will open each
file, jump to the target cell, identify the number string, extract it, and
then save the file using that number string. So, the file curently called '58
Green Ban' will be opened, 3378 extracted from within a text string and then
that file saved with the name 3378.

This is big and hairy and anyone who can do this should win the nobel excel
prize for being obsenely brainy.

Thanks in advance.

Gordon.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default The Ultimate Problem

Hi Gordon

Here's code that opens all files in a folder:
http://www.contextures.com/xlfaqMac.html#LoopBooks

Combine a modified version of it with code that reads a cell value, like

Dim S As String
S = wb.Sheets(1).Range("B14").Value

and code that saves the workbook as that (you figure that out yourself, hint
Macro recorder :-) -and you've earned yourself your very own nobel prize.

HTH. Best wishes Harald

"Gordon" skrev i melding
...
Hi.

I have a big problem and this might be a bridge too far for those that

have
always come to my aid in the past.

The problem. I have @5000 Excel files that hold product details in a

folder
called FILES. Each file is randomly titled. Each file is has been created
from a base template so they are all identical in format but different in
content. Each product is identified by a product number. However the

product
number shares a cell with random text. eg. Green bananas pn 3378 and

yellow
bananas pn 7765. What I need to do is run some excel code that will open

each
file, jump to the target cell, identify the number string, extract it, and
then save the file using that number string. So, the file curently called

'58
Green Ban' will be opened, 3378 extracted from within a text string and

then
that file saved with the name 3378.

This is big and hairy and anyone who can do this should win the nobel

excel
prize for being obsenely brainy.

Thanks in advance.

Gordon.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default The Ultimate Problem

Gordon
This might work for you. I assumed that the folder FILES was under the
root folder (C:\FILES). I also assumed that you wanted the old files
removed from the hard drive. HTH Otto
Sub AllFolderFiles()
Dim wb As Workbook
Dim TheFile As String
Dim MyPath As String
Dim NewName As String
MyPath = "C:\FILES"
ChDir MyPath
TheFile = Dir("*.xls")
Application.ScreenUpdating = False
Do While TheFile < ""
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
wb.Activate
NewName = Right(Sheets("Sheet1").Range("A1"), 4)
wb.SaveAs wb.Path & "\" & NewName & ".xls"
Application.DisplayAlerts = False
wb.Close
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
wb.Activate
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close
Application.DisplayAlerts = True
TheFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
"Gordon" wrote in message
...
Hi.

I have a big problem and this might be a bridge too far for those that
have
always come to my aid in the past.

The problem. I have @5000 Excel files that hold product details in a
folder
called FILES. Each file is randomly titled. Each file is has been created
from a base template so they are all identical in format but different in
content. Each product is identified by a product number. However the
product
number shares a cell with random text. eg. Green bananas pn 3378 and
yellow
bananas pn 7765. What I need to do is run some excel code that will open
each
file, jump to the target cell, identify the number string, extract it, and
then save the file using that number string. So, the file curently called
'58
Green Ban' will be opened, 3378 extracted from within a text string and
then
that file saved with the name 3378.

This is big and hairy and anyone who can do this should win the nobel
excel
prize for being obsenely brainy.

Thanks in advance.

Gordon.



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
My ultimate goal is to create an ID that will always be unique KR Excel Programming 0 May 15th 06 02:13 PM
My ultimate goal is to create an ID that will always be unique RB Smissaert Excel Programming 0 May 12th 06 02:18 PM
The ultimate Reference Guide to VBA in Excel Martin Knudsen Excel Programming 7 February 9th 06 09:24 AM
Ultimate protection shnim1 Excel Discussion (Misc queries) 1 October 18th 05 02:11 AM
Ultimate circular problem for chart creation nick g Excel Discussion (Misc queries) 1 July 26th 05 01:18 PM


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