I'm trying to create what I thought should be a really simple Macro. I deal with the same report every day, which is updated each morning. That said, it would be really nice for me to be able to have the data I worked with yesterday in the same workbook as the new data from a given morning.
Basically, all I want to do is copy a worksheet from a different workbook (the one with yesterday's report) into my active workbook (the one with today's report) using a file browser.
The Application.GetOpenFilename method opens up a file browser like what I want, but I can't figure out how to use the directory string that it returns to copy in the worksheet I want.
Here's the code I've been using:
Sub Macro5()
Dim todayWBName As String
Dim yesterdayWB As Workbook
Set todayWB = ActiveWorkbook
todayWBName = todayWB.Name
'open file from last business day
yesterdayWBName = Application.GetOpenFilename( _
Title:="Select backorder file from last business day", _
MultiSelect:=False)
If yesterdayWBName = False Then
Exit Sub
Else
End If
Workbooks.Open yesterdayWBName
Set yesterdayWB = ActiveWorkbook
todayWB.Activate
'copy in yesterday's info
yesterdayWB(1).Copy After:=todayWB.Sheets(1)
yesterdayWB.Close
Sheets("Sheet 1 (2)").Name = "YesterdayResolution"
Sheets(1).Activate
End Sub
If anyone could tell me what I'm doing wrong here, I'd really appreciate it.
Thanks in advance.