Copy Past of sheets.

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,059
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have this code and is all perfect, then only think is it is taking time as Filling cells

Is there a way as to reduce the time take
As it creates a new workbook and then moves 2 sheets form old to new.

VBA Code:
Sub SaveFileMN()
Dim sFilename As String

Workbooks("Fiserv Intraday Generator Hourly V1.xlsb").Activate
sFilename = Sheets("Email").Range("F5").Value & ".xlsx"

Workbooks.Add
'Saving the Workbook
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "ISFAtt" & "\" & sFilename
Application.Calculation = xlCalculationManual
Set w1 = Workbooks("Fiserv Intraday Generator Hourly V1.xlsb")
Set W2 = Workbooks(sFilename)
w1.Sheets("Summary_US").Copy Before:=Workbooks(sFilename).Sheets(1)
ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value

Set w1 = Workbooks("Fiserv Intraday Generator Hourly V1.xlsb")
Set W2 = Workbooks(sFilename)
w1.Sheets("US Intraday Hourly - EOD ").Copy After:=Workbooks(sFilename).Sheets("Summary_US")
End sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this:
VBA Code:
Sub SaveFileMN()
Dim sFilename As String

Application.ScreenUpdating = False          '<---------

Workbooks("Fiserv Intraday Generator Hourly V1.xlsb").Activate
sFilename = Sheets("Email").Range("F5").Value & ".xlsx"

Workbooks.Add
'Saving the Workbook
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "ISFAtt" & "\" & sFilename
Application.Calculation = xlCalculationManual
Set w1 = Workbooks("Fiserv Intraday Generator Hourly V1.xlsb")
Set W2 = Workbooks(sFilename)
w1.Sheets("Summary_US").Copy Before:=Workbooks(sFilename).Sheets(1)
ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value

Set w1 = Workbooks("Fiserv Intraday Generator Hourly V1.xlsb")
Set W2 = Workbooks(sFilename)
w1.Sheets("US Intraday Hourly - EOD ").Copy After:=Workbooks(sFilename).Sheets("Summary_US")

Application.ScreenUpdating = True          '<-------
End sub
 
Upvote 0
Try this:
VBA Code:
Sub SaveFileMN()
Dim sFilename As String

Application.ScreenUpdating = False          '<---------

Workbooks("Fiserv Intraday Generator Hourly V1.xlsb").Activate
sFilename = Sheets("Email").Range("F5").Value & ".xlsx"

Workbooks.Add
'Saving the Workbook
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "ISFAtt" & "\" & sFilename
Application.Calculation = xlCalculationManual
Set w1 = Workbooks("Fiserv Intraday Generator Hourly V1.xlsb")
Set W2 = Workbooks(sFilename)
w1.Sheets("Summary_US").Copy Before:=Workbooks(sFilename).Sheets(1)
ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value

Set w1 = Workbooks("Fiserv Intraday Generator Hourly V1.xlsb")
Set W2 = Workbooks(sFilename)
w1.Sheets("US Intraday Hourly - EOD ").Copy After:=Workbooks(sFilename).Sheets("Summary_US")

Application.ScreenUpdating = True          '<-------
End sub
sure will give it a try, tomorrow. thanks
 
Upvote 0
Try this:
VBA Code:
Sub SaveFileMN()
Dim sFilename As String

Application.ScreenUpdating = False          '<---------

Workbooks("Fiserv Intraday Generator Hourly V1.xlsb").Activate
sFilename = Sheets("Email").Range("F5").Value & ".xlsx"

Workbooks.Add
'Saving the Workbook
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "ISFAtt" & "\" & sFilename
Application.Calculation = xlCalculationManual
Set w1 = Workbooks("Fiserv Intraday Generator Hourly V1.xlsb")
Set W2 = Workbooks(sFilename)
w1.Sheets("Summary_US").Copy Before:=Workbooks(sFilename).Sheets(1)
ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value

Set w1 = Workbooks("Fiserv Intraday Generator Hourly V1.xlsb")
Set W2 = Workbooks(sFilename)
w1.Sheets("US Intraday Hourly - EOD ").Copy After:=Workbooks(sFilename).Sheets("Summary_US")

Application.ScreenUpdating = True          '<-------
End sub
I tried it, but still it is taking time, is there any other alternative..
 
Upvote 0
Try This:

VBA Code:
Sub SaveFileMN()
    Dim sFilename As String
'
    Application.ScreenUpdating = False
'
    Workbooks("Fiserv Intraday Generator Hourly V1.xlsb").Activate
    sFilename = Sheets("Email").Range("F5").Value & ".xlsx"
'
    Workbooks.Add
'
'   Saving the Workbook
    ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "ISFAtt" & "\" & sFilename
'
    Workbooks("Fiserv Intraday Generator Hourly V1.xlsb").Worksheets(Array("Summary_US", "US Intraday Hourly - EOD ")).Copy Before:=Workbooks(sFilename).Sheets(1)
'
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
it is f
Try This:

VBA Code:
Sub SaveFileMN()
    Dim sFilename As String
'
    Application.ScreenUpdating = False
'
    Workbooks("Fiserv Intraday Generator Hourly V1.xlsb").Activate
    sFilename = Sheets("Email").Range("F5").Value & ".xlsx"
'
    Workbooks.Add
'
'   Saving the Workbook
    ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "ISFAtt" & "\" & sFilename
'
    Workbooks("Fiserv Intraday Generator Hourly V1.xlsb").Worksheets(Array("Summary_US", "US Intraday Hourly - EOD ")).Copy Before:=Workbooks(sFilename).Sheets(1)
'
    Application.ScreenUpdating = True
End Sub
It is much faster, but hw to convert it to values after copy. in this case we just need to convert sheet "Summary_US" to vales after copy to new file
 
Upvote 0
hi I modified a bit and it is all perfect and faster. thanks for the support

VBA Code:
Sub SaveFileA()
Dim sFilename As String

    
    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
'
    Workbooks("Fiserv Intraday Generator Hourly.xlsb").Activate
    sFilename = Sheets("Email").Range("C5").Value & ".xlsx"
'
    Workbooks.Add
'
'   Saving the Workbook
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "ISFAtt" & "\" & sFilename
    Application.DisplayAlerts = True
'
    Workbooks("Fiserv Intraday Generator Hourly.xlsb").Worksheets(Array("Summary_", "Fiserv US Intraday Hourly - EOD")).Copy Before:=Workbooks(sFilename).Sheets(1)
    Workbooks(sFilename).Activate
    Sheets("Summary_").Select
    Cells.Select
    Range("E13").Activate
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Range("E13").Select

    Application.ScreenUpdating = True

ActiveWorkbook.Save
ActiveWorkbook.Close
Application.Calculation = xlCalculationAutomatic
Call FilePathA
Sheets("Report").Select
 
Upvote 0
Happy to hear that it is working faster for you now.
 
Upvote 0

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top