Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
The overall goal is for my macro to copy a sheet from the active workbook,
paste it in a new workbook created by the macro. The user will then be asked to save the new workbook via the "save as" menu. Below is what I have so far. If anyone has a different method, please let me know. Option Explicit Private Sub CreateInfoFile_Click() Dim mod1name As String Dim infoname As String Dim newbook 'inserting full name of active file in Exported Sheet Sheets("ExportedSheet").Range("B1").Value = mod1name 'Creating New Workbook Set newbook = Workbooks.Add With newbook .SaveAs Filename:="Blank.xls" End With 'Copy Exported Sheet to new file Sheets("ExportedSheet").Copy Befo=Workbooks("Blank.xls").Sheets(1) '*PROBLEM 'Deleting blank sheets Sheets("Sheet1").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet4").Select ActiveWindow.SelectedSheets.Delete 'Saving new file Do infoname = Application.GetSaveAsFilename Loop Until infoname < False newbook.SaveAs Filename:=infoname 'Getting filename and pasting in Exported Sheet Sheets("ExportedSheet").Range("B2").Value = infoname End Sub First, I create the newworkbook. No problem. Then I try and copy the sheet to it. As far as I know, to do this you have to activate the workbook with the "ExportedSheet" sheet. Since the name of this file will be changing, I need to refer to it some other way than it's real name. (That is where I was going with "mod1name".) So, is there a way to activate a window using a variable name? (I know you can open a file using a variable name.) Thanks in advance. -Chris |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel files in separate program windows | Excel Discussion (Misc queries) | |||
COUNTIF MULTIPLE CRITERIA | Excel Discussion (Misc queries) | |||
How to resize Data Form dialog window? | Excel Worksheet Functions | |||
How do I reset default Excel window too view=fullscreen | Setting up and Configuration of Excel | |||
Help resizes window &%$#! | Excel Discussion (Misc queries) |