Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How do you rename Multiple files using text from a cell in the file?

I could use some help writing my macro for excel. This is what I have:

1) I have 3 files in C:/sample named 1.xls, 2.xls, and 3.xls (this
varies from 2 - 30 files)
2) I need to save each one using text in cell E28

I would like:

1) An input prompt when Macro starts to ask how many files.
2) Then the Macro to run through all numbered files saving the file
using what text is in cell E28 as the new file name.

I have been able to get it to do the first file, but I can't get the
variable to change on the second and additional files.

Thanks for your Help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How do you rename Multiple files using text from a cell in the file?

Try this

Select the files you want in the open dialog that popup (use the Ctrl key)

It use E28 in the first sheet of each workbook
mybook.SaveAs Sheets(1).Range("E28") & ".xls"

Sub Example()
Dim mybook As Workbook
Dim N As Long
Dim MyPath As String
Dim SaveDriveDir As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = "C:\Data\"
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls", _
MultiSelect:=True)
If IsArray(FName) Then
Application.ScreenUpdating = False

For N = LBound(FName) To UBound(FName)
Set mybook = Workbooks.Open(FName(N))
mybook.SaveAs Sheets(1).Range("E28") & ".xls"
mybook.Close False
Next
End If
ChDrive SaveDriveDir
ChDir SaveDriveDir
Application.ScreenUpdating = True
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"RandyR" wrote in message oups.com...
I could use some help writing my macro for excel. This is what I have:

1) I have 3 files in C:/sample named 1.xls, 2.xls, and 3.xls (this
varies from 2 - 30 files)
2) I need to save each one using text in cell E28

I would like:

1) An input prompt when Macro starts to ask how many files.
2) Then the Macro to run through all numbered files saving the file
using what text is in cell E28 as the new file name.

I have been able to get it to do the first file, but I can't get the
variable to change on the second and additional files.

Thanks for your Help.



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
Automated multiple text files into multiple sheets in one workbook Dr Dan Excel Discussion (Misc queries) 14 November 4th 07 11:32 AM
Rename multiple csv files eliminating (-) hyphens from the label. simplymidori[_2_] Excel Discussion (Misc queries) 2 July 26th 07 11:34 PM
Rename Multiple Excel Workbooks based on cell contents Scott Campbell[_2_] Excel Discussion (Misc queries) 4 April 24th 07 10:00 PM
merge multiple files from text list of file pairs rroach[_5_] Excel Programming 2 June 14th 05 01:17 PM
Copy worksheet from multiple files in one DIR to another DIR & rename Mike Taylor Excel Programming 1 July 13th 03 03:28 PM


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