Copy and Paste Between Multiple Sheets

blu817

New Member
Joined
Aug 18, 2017
Messages
20
I am trying to create a macro that consolidates multiple excel spreadsheets. Now this macro will be ran everyday so the save date varies and the spreadsheets that I am copying are in a share drive. My approach to doing this was to open a new spreadsheet save it as today's date and call the other files in the share drive, copy the sheets and paste them into the consolidated file. The issue I am running into is after copying the sheet the macro is unable to recall the consolidated sheet because of the varying dates. I am still new to VBA and have tried multiple things and lost at this point. The code I've written is below and any suggestions/help with be greatly appreciated.


Sub Consolidated_Sheet()






Dim wb As Workbook
Set wb = Workbooks.Add
Dim XlsFolder As String
Dim fname As String
Dim Newbook As Workbook
Dim SaveFile As String
Dim myWS As Worksheet
XlsFolder = "U:\TSClearing\Best Execution\Limited Quotation Exceptions\Consolidated LQ"






'Save Consolidated
ActiveWorkbook.SaveAs Filename:= _
"U:\TSClearing\Best Execution\Limited Quotation Exceptions\Consolidated LQ" & Format(WorksheetFunction.WorkDay(Date, -1), "mmddyy") & ".xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

Workbooks.Open Filename:= _
"U:\TSClearing\Best Execution\Limited Quotation Exceptions\Consolidated LQ" & Format(WorksheetFunction.WorkDay(Date, -1), "mmddyy") & ".xlsx"


'Open KCG file
Workbooks.Open Filename:= _
"U:\TSClearing\Best Execution\Limited Quotation Exceptions\KCG\NITE_" & Format(WorksheetFunction.WorkDay(Date, -1), "mmddyy") & ".xls"


Columns("A:AC").Select
Selection.Copy
'this next line is where I am having issue, looks like it cant recall based on workday
Windows("WorkDay(Date, -1).xlsx").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False











End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,214,912
Messages
6,122,200
Members
449,072
Latest member
DW Draft

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