Macro Copy from one Spreadsheet to Another with different Names

kulfon1221

New Member
Joined
Sep 15, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

Hopefully someone could help, I currently working on building a master spreadsheet to pull data from different sources.

Daily report is populated daily by system and it always same name for example "qwerty_Date_Time" The only problem is that the time is different everyday so it would be 10am or 12pm

Is there a way of setting VBA to ignore the Time stamp and go by the date and just copy whole file and copy under yesterday's data so for example I will have whole month in one row.

Thank you
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi Everyone,

Hopefully someone could help, I currently working on building a master spreadsheet to pull data from different sources.

Daily report is populated daily by system and it always same name for example "qwerty_Date_Time" The only problem is that the time is different everyday so it would be 10am or 12pm

Is there a way of setting VBA to ignore the Time stamp and go by the date and just copy whole file and copy under yesterday's data so for example I will have whole month in one row.

Thank you

Hi. Try the below.

VBA Code:
'Specify the date format used by the system file (e.g.; "yyyy-mm-dd")
Dim fmtDt As String: fmtDt = Format(Date, "yyyy-mm-dd")

Dim mypath As String, sFilename As String

'update mypath to suit
mypath = "C:\Users\" & Environ("username") & "\OneDrive\Desktop"
'use the wildcard (*) in place of time
mypath = mypath & "\qwerty_" & fmtDt & "_*"
sFilename = Dir(mypath)
Workbooks.Open Filename:=sFilename
 
Upvote 0

Forum statistics

Threads
1,215,696
Messages
6,126,267
Members
449,308
Latest member
VerifiedBleachersAttendee

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