Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Automated multiple text files into multiple sheets in one workbook | Excel Discussion (Misc queries) | |||
Rename multiple csv files eliminating (-) hyphens from the label. | Excel Discussion (Misc queries) | |||
Rename Multiple Excel Workbooks based on cell contents | Excel Discussion (Misc queries) | |||
merge multiple files from text list of file pairs | Excel Programming | |||
Copy worksheet from multiple files in one DIR to another DIR & rename | Excel Programming |