PC Review


Reply
Thread Tools Rate Thread

Copy macro to a new book in 2007

 
 
=?Utf-8?B?bHdpZGpheWE=?=
Guest
Posts: n/a
 
      1st Oct 2007
I have a master file with a macro in it. When I click a button, the macro
will copy 3 sheets from the master file to a new book. I have macros in 2 of
the sheets that I copy. It works fine (meaning the macros are copied over to
the new book also) until the macro runs the saveas function:
ActiveWorkbook.SaveCopyAs "C:\New\" & NewName & ".xls"
The new file doesn't have any macro in it.
I tried saving the new file as .xlsm and .xlsx but Excel doesn't recognize
the file extensions when I open the new file.
What should I do to keep the macro in the new file?
Thanks in advance.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?bHdpZGpheWE=?=
Guest
Posts: n/a
 
      1st Oct 2007
Hi Ron,
thanks a lot! It works for me.
I have another question, how do I copy just a range of cells from each
sheets? Actually, I don't want to include column A. I'm using
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy right now and it copies all
cells in the sheets.

Thanks!



"Ron de Bruin" wrote:

> Hi lwidjaya
>
> See
> http://www.rondebruin.nl/saveas.htm
>
> I use
> ActiveSheet.Copy
>
> But you can also use this to copy more sheets
> Sheets(Array("Sheet1", "Sheet3")).Copy
>
>
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "lwidjaya" <(E-Mail Removed)> wrote in message news:B23B9805-CBB5-4D10-A757-(E-Mail Removed)...
> >I have a master file with a macro in it. When I click a button, the macro
> > will copy 3 sheets from the master file to a new book. I have macros in 2 of
> > the sheets that I copy. It works fine (meaning the macros are copied over to
> > the new book also) until the macro runs the saveas function:
> > ActiveWorkbook.SaveCopyAs "C:\New\" & NewName & ".xls"
> > The new file doesn't have any macro in it.
> > I tried saving the new file as .xlsm and .xlsx but Excel doesn't recognize
> > the file extensions when I open the new file.
> > What should I do to keep the macro in the new file?
> > Thanks in advance.

>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      1st Oct 2007
Try this one

Sub Copy_Test()
'Working in Excel 97-2007
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim sh As Worksheet

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set Sourcewb = ActiveWorkbook

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy
Set Destwb = ActiveWorkbook

For Each sh In Destwb.Worksheets
sh.Columns("A").Delete
Next sh

'Determine the Excel version and file extension/format
With Destwb
If Val(Application.Version) < 12 Then
'You use Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
'We exit the sub when your answer is NO in the security dialog that you
'only see when you copy a sheet from a xlsm file with macro's disabled.
If Sourcewb.Name = .Name Then
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
MsgBox "Your answer is NO in the security dialog"
Exit Sub
Else
Select Case Sourcewb.FileFormat
Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
Case 52:
If .HasVBProject Then
FileExtStr = ".xlsm": FileFormatNum = 52
Else
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Case 56: FileExtStr = ".xls": FileFormatNum = 56
Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
End Select
End If
End If
End With

'Save the new workbook and close it
TempFilePath = Application.DefaultFilePath & "\"
TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")

With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
.Close SaveChanges:=False
End With

MsgBox "You can find the new file in " & Application.DefaultFilePath

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"lwidjaya" <(E-Mail Removed)> wrote in message news:4E15DA93-5FDE-44F4-9C44-(E-Mail Removed)...
> Hi Ron,
> thanks a lot! It works for me.
> I have another question, how do I copy just a range of cells from each
> sheets? Actually, I don't want to include column A. I'm using
> Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy right now and it copies all
> cells in the sheets.
>
> Thanks!
>
>
>
> "Ron de Bruin" wrote:
>
>> Hi lwidjaya
>>
>> See
>> http://www.rondebruin.nl/saveas.htm
>>
>> I use
>> ActiveSheet.Copy
>>
>> But you can also use this to copy more sheets
>> Sheets(Array("Sheet1", "Sheet3")).Copy
>>
>>
>>
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.nl/tips.htm
>>
>>
>> "lwidjaya" <(E-Mail Removed)> wrote in message news:B23B9805-CBB5-4D10-A757-(E-Mail Removed)...
>> >I have a master file with a macro in it. When I click a button, the macro
>> > will copy 3 sheets from the master file to a new book. I have macros in 2 of
>> > the sheets that I copy. It works fine (meaning the macros are copied over to
>> > the new book also) until the macro runs the saveas function:
>> > ActiveWorkbook.SaveCopyAs "C:\New\" & NewName & ".xls"
>> > The new file doesn't have any macro in it.
>> > I tried saving the new file as .xlsm and .xlsx but Excel doesn't recognize
>> > the file extensions when I open the new file.
>> > What should I do to keep the macro in the new file?
>> > Thanks in advance.

>>

 
Reply With Quote
 
=?Utf-8?B?bHdpZGpheWE=?=
Guest
Posts: n/a
 
      1st Oct 2007
Thanks Ron. I think I said it wrong. Actually, I have a button with macro in
sheet 1 and I place it in column A. Stupid me, I thought deleting the column
will delete the button. My intention was to delete the button/macro in the
sheet 1 in the new file. How do I do that?

Thanks!

"Ron de Bruin" wrote:

> Try this one
>
> Sub Copy_Test()
> 'Working in Excel 97-2007
> Dim FileExtStr As String
> Dim FileFormatNum As Long
> Dim Sourcewb As Workbook
> Dim Destwb As Workbook
> Dim TempFilePath As String
> Dim TempFileName As String
> Dim sh As Worksheet
>
> With Application
> .ScreenUpdating = False
> .EnableEvents = False
> End With
>
> Set Sourcewb = ActiveWorkbook
>
> Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy
> Set Destwb = ActiveWorkbook
>
> For Each sh In Destwb.Worksheets
> sh.Columns("A").Delete
> Next sh
>
> 'Determine the Excel version and file extension/format
> With Destwb
> If Val(Application.Version) < 12 Then
> 'You use Excel 97-2003
> FileExtStr = ".xls": FileFormatNum = -4143
> Else
> 'You use Excel 2007
> 'We exit the sub when your answer is NO in the security dialog that you
> 'only see when you copy a sheet from a xlsm file with macro's disabled.
> If Sourcewb.Name = .Name Then
> With Application
> .ScreenUpdating = True
> .EnableEvents = True
> End With
> MsgBox "Your answer is NO in the security dialog"
> Exit Sub
> Else
> Select Case Sourcewb.FileFormat
> Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
> Case 52:
> If .HasVBProject Then
> FileExtStr = ".xlsm": FileFormatNum = 52
> Else
> FileExtStr = ".xlsx": FileFormatNum = 51
> End If
> Case 56: FileExtStr = ".xls": FileFormatNum = 56
> Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
> End Select
> End If
> End If
> End With
>
> 'Save the new workbook and close it
> TempFilePath = Application.DefaultFilePath & "\"
> TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
>
> With Destwb
> .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
> .Close SaveChanges:=False
> End With
>
> MsgBox "You can find the new file in " & Application.DefaultFilePath
>
> With Application
> .ScreenUpdating = True
> .EnableEvents = True
> End With
> End Sub
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "lwidjaya" <(E-Mail Removed)> wrote in message news:4E15DA93-5FDE-44F4-9C44-(E-Mail Removed)...
> > Hi Ron,
> > thanks a lot! It works for me.
> > I have another question, how do I copy just a range of cells from each
> > sheets? Actually, I don't want to include column A. I'm using
> > Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy right now and it copies all
> > cells in the sheets.
> >
> > Thanks!
> >
> >
> >
> > "Ron de Bruin" wrote:
> >
> >> Hi lwidjaya
> >>
> >> See
> >> http://www.rondebruin.nl/saveas.htm
> >>
> >> I use
> >> ActiveSheet.Copy
> >>
> >> But you can also use this to copy more sheets
> >> Sheets(Array("Sheet1", "Sheet3")).Copy
> >>
> >>
> >>
> >>
> >> --
> >>
> >> Regards Ron de Bruin
> >> http://www.rondebruin.nl/tips.htm
> >>
> >>
> >> "lwidjaya" <(E-Mail Removed)> wrote in message news:B23B9805-CBB5-4D10-A757-(E-Mail Removed)...
> >> >I have a master file with a macro in it. When I click a button, the macro
> >> > will copy 3 sheets from the master file to a new book. I have macros in 2 of
> >> > the sheets that I copy. It works fine (meaning the macros are copied over to
> >> > the new book also) until the macro runs the saveas function:
> >> > ActiveWorkbook.SaveCopyAs "C:\New\" & NewName & ".xls"
> >> > The new file doesn't have any macro in it.
> >> > I tried saving the new file as .xlsm and .xlsx but Excel doesn't recognize
> >> > the file extensions when I open the new file.
> >> > What should I do to keep the macro in the new file?
> >> > Thanks in advance.
> >>

>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      1st Oct 2007
You can change the properties of the button and use the last macro or use this one
to delete the DrawingObjects in "Sheet1"

Sub Copy_Test()
'Working in Excel 97-2007
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set Sourcewb = ActiveWorkbook

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy
Set Destwb = ActiveWorkbook

On Error Resume Next
With Destwb.Worksheets("Sheet1")
.DrawingObjects.Visible = True
.DrawingObjects.Delete
End With
On Error GoTo 0


'Determine the Excel version and file extension/format
With Destwb
If Val(Application.Version) < 12 Then
'You use Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
'We exit the sub when your answer is NO in the security dialog that you
'only see when you copy a sheet from a xlsm file with macro's disabled.
If Sourcewb.Name = .Name Then
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
MsgBox "Your answer is NO in the security dialog"
Exit Sub
Else
Select Case Sourcewb.FileFormat
Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
Case 52:
If .HasVBProject Then
FileExtStr = ".xlsm": FileFormatNum = 52
Else
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Case 56: FileExtStr = ".xls": FileFormatNum = 56
Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
End Select
End If
End If
End With

'Save the new workbook and close it
TempFilePath = Application.DefaultFilePath & "\"
TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")

With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
.Close SaveChanges:=False
End With

MsgBox "You can find the new file in " & Application.DefaultFilePath

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"lwidjaya" <(E-Mail Removed)> wrote in message news:E688CD37-8E30-478E-9177-(E-Mail Removed)...
> Thanks Ron. I think I said it wrong. Actually, I have a button with macro in
> sheet 1 and I place it in column A. Stupid me, I thought deleting the column
> will delete the button. My intention was to delete the button/macro in the
> sheet 1 in the new file. How do I do that?
>
> Thanks!
>
> "Ron de Bruin" wrote:
>
>> Try this one
>>
>> Sub Copy_Test()
>> 'Working in Excel 97-2007
>> Dim FileExtStr As String
>> Dim FileFormatNum As Long
>> Dim Sourcewb As Workbook
>> Dim Destwb As Workbook
>> Dim TempFilePath As String
>> Dim TempFileName As String
>> Dim sh As Worksheet
>>
>> With Application
>> .ScreenUpdating = False
>> .EnableEvents = False
>> End With
>>
>> Set Sourcewb = ActiveWorkbook
>>
>> Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy
>> Set Destwb = ActiveWorkbook
>>
>> For Each sh In Destwb.Worksheets
>> sh.Columns("A").Delete
>> Next sh
>>
>> 'Determine the Excel version and file extension/format
>> With Destwb
>> If Val(Application.Version) < 12 Then
>> 'You use Excel 97-2003
>> FileExtStr = ".xls": FileFormatNum = -4143
>> Else
>> 'You use Excel 2007
>> 'We exit the sub when your answer is NO in the security dialog that you
>> 'only see when you copy a sheet from a xlsm file with macro's disabled.
>> If Sourcewb.Name = .Name Then
>> With Application
>> .ScreenUpdating = True
>> .EnableEvents = True
>> End With
>> MsgBox "Your answer is NO in the security dialog"
>> Exit Sub
>> Else
>> Select Case Sourcewb.FileFormat
>> Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
>> Case 52:
>> If .HasVBProject Then
>> FileExtStr = ".xlsm": FileFormatNum = 52
>> Else
>> FileExtStr = ".xlsx": FileFormatNum = 51
>> End If
>> Case 56: FileExtStr = ".xls": FileFormatNum = 56
>> Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
>> End Select
>> End If
>> End If
>> End With
>>
>> 'Save the new workbook and close it
>> TempFilePath = Application.DefaultFilePath & "\"
>> TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
>>
>> With Destwb
>> .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
>> .Close SaveChanges:=False
>> End With
>>
>> MsgBox "You can find the new file in " & Application.DefaultFilePath
>>
>> With Application
>> .ScreenUpdating = True
>> .EnableEvents = True
>> End With
>> End Sub
>>
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.nl/tips.htm
>>
>>
>> "lwidjaya" <(E-Mail Removed)> wrote in message news:4E15DA93-5FDE-44F4-9C44-(E-Mail Removed)...
>> > Hi Ron,
>> > thanks a lot! It works for me.
>> > I have another question, how do I copy just a range of cells from each
>> > sheets? Actually, I don't want to include column A. I'm using
>> > Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy right now and it copies all
>> > cells in the sheets.
>> >
>> > Thanks!
>> >
>> >
>> >
>> > "Ron de Bruin" wrote:
>> >
>> >> Hi lwidjaya
>> >>
>> >> See
>> >> http://www.rondebruin.nl/saveas.htm
>> >>
>> >> I use
>> >> ActiveSheet.Copy
>> >>
>> >> But you can also use this to copy more sheets
>> >> Sheets(Array("Sheet1", "Sheet3")).Copy
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >>
>> >> Regards Ron de Bruin
>> >> http://www.rondebruin.nl/tips.htm
>> >>
>> >>
>> >> "lwidjaya" <(E-Mail Removed)> wrote in message news:B23B9805-CBB5-4D10-A757-(E-Mail Removed)...
>> >> >I have a master file with a macro in it. When I click a button, the macro
>> >> > will copy 3 sheets from the master file to a new book. I have macros in 2 of
>> >> > the sheets that I copy. It works fine (meaning the macros are copied over to
>> >> > the new book also) until the macro runs the saveas function:
>> >> > ActiveWorkbook.SaveCopyAs "C:\New\" & NewName & ".xls"
>> >> > The new file doesn't have any macro in it.
>> >> > I tried saving the new file as .xlsm and .xlsx but Excel doesn't recognize
>> >> > the file extensions when I open the new file.
>> >> > What should I do to keep the macro in the new file?
>> >> > Thanks in advance.
>> >>

>>

 
Reply With Quote
 
=?Utf-8?B?bHdpZGpheWE=?=
Guest
Posts: n/a
 
      1st Oct 2007
Thanks sooo..much... I was able to make it work!


"Ron de Bruin" wrote:

> You can change the properties of the button and use the last macro or use this one
> to delete the DrawingObjects in "Sheet1"
>
> Sub Copy_Test()
> 'Working in Excel 97-2007
> Dim FileExtStr As String
> Dim FileFormatNum As Long
> Dim Sourcewb As Workbook
> Dim Destwb As Workbook
> Dim TempFilePath As String
> Dim TempFileName As String
>
> With Application
> .ScreenUpdating = False
> .EnableEvents = False
> End With
>
> Set Sourcewb = ActiveWorkbook
>
> Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy
> Set Destwb = ActiveWorkbook
>
> On Error Resume Next
> With Destwb.Worksheets("Sheet1")
> .DrawingObjects.Visible = True
> .DrawingObjects.Delete
> End With
> On Error GoTo 0
>
>
> 'Determine the Excel version and file extension/format
> With Destwb
> If Val(Application.Version) < 12 Then
> 'You use Excel 97-2003
> FileExtStr = ".xls": FileFormatNum = -4143
> Else
> 'You use Excel 2007
> 'We exit the sub when your answer is NO in the security dialog that you
> 'only see when you copy a sheet from a xlsm file with macro's disabled.
> If Sourcewb.Name = .Name Then
> With Application
> .ScreenUpdating = True
> .EnableEvents = True
> End With
> MsgBox "Your answer is NO in the security dialog"
> Exit Sub
> Else
> Select Case Sourcewb.FileFormat
> Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
> Case 52:
> If .HasVBProject Then
> FileExtStr = ".xlsm": FileFormatNum = 52
> Else
> FileExtStr = ".xlsx": FileFormatNum = 51
> End If
> Case 56: FileExtStr = ".xls": FileFormatNum = 56
> Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
> End Select
> End If
> End If
> End With
>
> 'Save the new workbook and close it
> TempFilePath = Application.DefaultFilePath & "\"
> TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
>
> With Destwb
> .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
> .Close SaveChanges:=False
> End With
>
> MsgBox "You can find the new file in " & Application.DefaultFilePath
>
> With Application
> .ScreenUpdating = True
> .EnableEvents = True
> End With
> End Sub
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "lwidjaya" <(E-Mail Removed)> wrote in message news:E688CD37-8E30-478E-9177-(E-Mail Removed)...
> > Thanks Ron. I think I said it wrong. Actually, I have a button with macro in
> > sheet 1 and I place it in column A. Stupid me, I thought deleting the column
> > will delete the button. My intention was to delete the button/macro in the
> > sheet 1 in the new file. How do I do that?
> >
> > Thanks!
> >
> > "Ron de Bruin" wrote:
> >
> >> Try this one
> >>
> >> Sub Copy_Test()
> >> 'Working in Excel 97-2007
> >> Dim FileExtStr As String
> >> Dim FileFormatNum As Long
> >> Dim Sourcewb As Workbook
> >> Dim Destwb As Workbook
> >> Dim TempFilePath As String
> >> Dim TempFileName As String
> >> Dim sh As Worksheet
> >>
> >> With Application
> >> .ScreenUpdating = False
> >> .EnableEvents = False
> >> End With
> >>
> >> Set Sourcewb = ActiveWorkbook
> >>
> >> Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy
> >> Set Destwb = ActiveWorkbook
> >>
> >> For Each sh In Destwb.Worksheets
> >> sh.Columns("A").Delete
> >> Next sh
> >>
> >> 'Determine the Excel version and file extension/format
> >> With Destwb
> >> If Val(Application.Version) < 12 Then
> >> 'You use Excel 97-2003
> >> FileExtStr = ".xls": FileFormatNum = -4143
> >> Else
> >> 'You use Excel 2007
> >> 'We exit the sub when your answer is NO in the security dialog that you
> >> 'only see when you copy a sheet from a xlsm file with macro's disabled.
> >> If Sourcewb.Name = .Name Then
> >> With Application
> >> .ScreenUpdating = True
> >> .EnableEvents = True
> >> End With
> >> MsgBox "Your answer is NO in the security dialog"
> >> Exit Sub
> >> Else
> >> Select Case Sourcewb.FileFormat
> >> Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
> >> Case 52:
> >> If .HasVBProject Then
> >> FileExtStr = ".xlsm": FileFormatNum = 52
> >> Else
> >> FileExtStr = ".xlsx": FileFormatNum = 51
> >> End If
> >> Case 56: FileExtStr = ".xls": FileFormatNum = 56
> >> Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
> >> End Select
> >> End If
> >> End If
> >> End With
> >>
> >> 'Save the new workbook and close it
> >> TempFilePath = Application.DefaultFilePath & "\"
> >> TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
> >>
> >> With Destwb
> >> .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
> >> .Close SaveChanges:=False
> >> End With
> >>
> >> MsgBox "You can find the new file in " & Application.DefaultFilePath
> >>
> >> With Application
> >> .ScreenUpdating = True
> >> .EnableEvents = True
> >> End With
> >> End Sub
> >>
> >>
> >> --
> >>
> >> Regards Ron de Bruin
> >> http://www.rondebruin.nl/tips.htm
> >>
> >>
> >> "lwidjaya" <(E-Mail Removed)> wrote in message news:4E15DA93-5FDE-44F4-9C44-(E-Mail Removed)...
> >> > Hi Ron,
> >> > thanks a lot! It works for me.
> >> > I have another question, how do I copy just a range of cells from each
> >> > sheets? Actually, I don't want to include column A. I'm using
> >> > Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy right now and it copies all
> >> > cells in the sheets.
> >> >
> >> > Thanks!
> >> >
> >> >
> >> >
> >> > "Ron de Bruin" wrote:
> >> >
> >> >> Hi lwidjaya
> >> >>
> >> >> See
> >> >> http://www.rondebruin.nl/saveas.htm
> >> >>
> >> >> I use
> >> >> ActiveSheet.Copy
> >> >>
> >> >> But you can also use this to copy more sheets
> >> >> Sheets(Array("Sheet1", "Sheet3")).Copy
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >>
> >> >> Regards Ron de Bruin
> >> >> http://www.rondebruin.nl/tips.htm
> >> >>
> >> >>
> >> >> "lwidjaya" <(E-Mail Removed)> wrote in message news:B23B9805-CBB5-4D10-A757-(E-Mail Removed)...
> >> >> >I have a master file with a macro in it. When I click a button, the macro
> >> >> > will copy 3 sheets from the master file to a new book. I have macros in 2 of
> >> >> > the sheets that I copy. It works fine (meaning the macros are copied over to
> >> >> > the new book also) until the macro runs the saveas function:
> >> >> > ActiveWorkbook.SaveCopyAs "C:\New\" & NewName & ".xls"
> >> >> > The new file doesn't have any macro in it.
> >> >> > I tried saving the new file as .xlsm and .xlsx but Excel doesn't recognize
> >> >> > the file extensions when I open the new file.
> >> >> > What should I do to keep the macro in the new file?
> >> >> > Thanks in advance.
> >> >>
> >>

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to copy a one worksheet in one book to the current workbook Frank Pytel Microsoft Excel Programming 4 23rd Jun 2009 09:52 AM
Macro to copy a one worksheet in one book to the current workbook Frank Pytel Microsoft Excel Programming 5 19th Jun 2009 12:16 AM
copy 2007 created macro to run in 2003 amaries Microsoft Excel Misc 4 18th Dec 2008 07:48 PM
Re: Copy macro to a new book in 2007 Ron de Bruin Microsoft Excel Programming 0 1st Oct 2007 06:32 PM
macro to copy specific rows to a new book Karen W Microsoft Excel Programming 1 24th Feb 2005 06:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:25 AM.