Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default rename folder o files with value from inside each wbk

I have a folder full of workbooks each of which takes its name from the
value in sheet 1 cell E1 (which is the date the workbook was created).
Each name is unique, but the format varies.
Is there a way to rename all the workbooks (using the value in sheet 1 cell
e1), so that they all have the same date format?

Any help at all will be much appreciated.

Thanks,
DL


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default rename folder o files with value from inside each wbk

Max,

Sub testit()
Dim strPath As String, strFilter As String, strFile As String, strTemp
As String
Dim arr() As String, i As Long, wkb As Workbook

strPath = "C:\T\"

ReDim arr(0)
strFile = Dir(strPath & "*.xls")
If strFile < "" Then
Do Until strFile = ""
i = UBound(arr) + 1
ReDim Preserve arr(i)
arr(i) = strPath & strFile
strFile = Dir
Loop
End If
For i = 1 To UBound(arr)
Set wkb = Workbooks.Open(arr(i))
strTemp = Environ("COMSPEC") & " /c rename """ & arr(i) & """ """ &
_
Format(wkb.Worksheets(1).Range("E1"), "yyyymmdd") &
".xls"""
wkb.Close False
Set wkb = Nothing
Shell strTemp
Next
End Sub


Rob

"Max Bialystock" wrote in message
...
I have a folder full of workbooks each of which takes its name from the
value in sheet 1 cell E1 (which is the date the workbook was created).
Each name is unique, but the format varies.
Is there a way to rename all the workbooks (using the value in sheet 1

cell
e1), so that they all have the same date format?

Any help at all will be much appreciated.

Thanks,
DL




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default rename folder o files with value from inside each wbk

Ron,

Bloody Marvellous!!!

Thank you!!!

Max



"Rob van Gelder" wrote in message
...
Max,

Sub testit()
Dim strPath As String, strFilter As String, strFile As String, strTemp
As String
Dim arr() As String, i As Long, wkb As Workbook

strPath = "C:\T\"

ReDim arr(0)
strFile = Dir(strPath & "*.xls")
If strFile < "" Then
Do Until strFile = ""
i = UBound(arr) + 1
ReDim Preserve arr(i)
arr(i) = strPath & strFile
strFile = Dir
Loop
End If
For i = 1 To UBound(arr)
Set wkb = Workbooks.Open(arr(i))
strTemp = Environ("COMSPEC") & " /c rename """ & arr(i) & """ """

&
_
Format(wkb.Worksheets(1).Range("E1"), "yyyymmdd") &
".xls"""
wkb.Close False
Set wkb = Nothing
Shell strTemp
Next
End Sub


Rob

"Max Bialystock" wrote in message
...
I have a folder full of workbooks each of which takes its name from the
value in sheet 1 cell E1 (which is the date the workbook was created).
Each name is unique, but the format varies.
Is there a way to rename all the workbooks (using the value in sheet 1

cell
e1), so that they all have the same date format?

Any help at all will be much appreciated.

Thanks,
DL






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
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
search folder/directory for a phrase inside excel files pwrichcreek Excel Discussion (Misc queries) 5 August 11th 08 09:39 PM
How to create a copy of a folder having five files in it, & rename Matthews Excel Worksheet Functions 1 November 7th 06 03:42 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
I would like to print the titles of files inside a folder. onenevadadollar Excel Worksheet Functions 1 November 17th 05 12:26 AM


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