I'm trying to use an Excel VBA script to do a few things in one routine, I'm not sure if it's possible.
I have two VBA scripts, one of which I worked out and one of which I used a "macro recorder" for, and somehow I need to put them together... here goes:
Sub SaveWorkbookAsNewFile()
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
Dim DStart As String
Dim DEnd As String
DStart = Application.InputBox("Please enter start date. (dd-mm-yyyy)")
DEnd = Application.InputBox("Please enter end date. (dd-mm-yyyy)")
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
ThisWorkbook.SaveAs DStart & " to " & DEnd
End Sub
This one works for the bit I need it for, which is to create 2 variables for a start & end date range, then save the document as that name.
Sub Macro2()
Rows("5624:5679").Select
Selection.Copy
Windows("01-08-2015 to 09-09-2015.xlsm").Activate
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
Windows("Dash 2014Test.xlsx").Activate
Sheets("Sheet2").Select
Rows("835:846").Select
Application.CutCopyMode = False
Selection.Copy
Windows("01-08-2015 to 09-09-2015.xlsm").Activate
Sheets("Sheet2").Select
ActiveSheet.Paste
Windows("Dash 2014Test.xlsx").Activate
Sheets("Sheet3").Select
Rows("1611:1620").Select
Application.CutCopyMode = False
Selection.Copy
Windows("01-08-2015 to 09-09-2015.xlsm").Activate
Sheets("Sheet3").Select
Range("A1").Select
ActiveSheet.Paste
Windows("Dash 2014Test.xlsx").Activate
End Sub
What I'd like to do is replace all the ranges in the second VBA script (the manual ranges) with the date variables from the first VBA script, for a one button solution (if possible). Any ideas? I've never been very good at working with dates in excel.