ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exporting selected tabs multiple times to different file names (https://www.excelbanter.com/excel-programming/401841-exporting-selected-tabs-multiple-times-different-file-names.html)

Ren

Exporting selected tabs multiple times to different file names
 
I have a file ("orinignal") that has tabs one, two, three.....

I want to write a macro to export tabs to seperate files and save them
automatically. FIle one would include tab one, two, three. File two would
include tab one, two, four, etc.

I know i can do

Sheets(Array("one", "two", "three")).Select
Sheets(Array("one", "two", "three")).Copy
ActiveWorkbook.SaveAs Filename:= _
"C:\one.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Windows("original.xls").Activate

My question is how do i get back to the original file without hardcoding the
file name like in windows("original.xls").active. Is there a method I can use
to get the file name and save it in a text string and refere it back by using
windows(string).activate .

I am also wondering how i can get a user input text box in excel so I can
ask the user where to save it. I can't remember the method and was probably
searching for the wrong terms in google.

Thanks,

Steven


Dave Peterson

Exporting selected tabs multiple times to different file names
 
Dim mySelection as Range
set mySelection = selection
'do your work
application.goto myselection



Ren wrote:

I have a file ("orinignal") that has tabs one, two, three.....

I want to write a macro to export tabs to seperate files and save them
automatically. FIle one would include tab one, two, three. File two would
include tab one, two, four, etc.

I know i can do

Sheets(Array("one", "two", "three")).Select
Sheets(Array("one", "two", "three")).Copy
ActiveWorkbook.SaveAs Filename:= _
"C:\one.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Windows("original.xls").Activate

My question is how do i get back to the original file without hardcoding the
file name like in windows("original.xls").active. Is there a method I can use
to get the file name and save it in a text string and refere it back by using
windows(string).activate .

I am also wondering how i can get a user input text box in excel so I can
ask the user where to save it. I can't remember the method and was probably
searching for the wrong terms in google.

Thanks,

Steven


--

Dave Peterson


All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com