Hi all, I have the following VBA which I've been using and works well. We have changed the way in which we label the file called abcd.xlsm
We now add a date to the name, so today's file is called abcd_20221017.xlsm (so we have added an underscore and the current date to the end of the file name. so yesterday's file was called abcd_20221016.xlsm.
I'm hoping to adjust the following code so it works with any file named abcd regardless of what comes after it. The file type will always be .xlsm
Would appreciate any help
Sub Copy_PasteSpecial_Method()
If Workbook_Is_Opened("abcd.xlsx") = False Then
MsgBox "Please open File ABCD.xlsm for this operation to occur.", vbCritical, "Try Again After Opening Workbook"
Exit Sub
End If
If Workbook_Is_Opened("Journal_7111_MM.xlsm") = False Then
MsgBox "Please open [Journal_7111_MM] for this operation to occur.", vbCritical, "Try Again After Opening Workbook"
Exit Sub
End If
Dim copyRange As Range
Set copyRange = Workbooks("abcd.xlsx").Worksheets("Sheet1").Range("A1:IZ2121")
Dim pasteRange As Range
Set pasteRange = Workbooks("Journal_7111_MM.xlsm").Worksheets("engine").Range("A1:IZ2121")
Application.Calculation = xlCalculationManual
pasteRange.Value = copyRange.Value
Set copyRange = Workbooks("abcd.xlsx").Worksheets("Sheet2").Range("A1:AXG2110")
Set pasteRange = Workbooks("Journal_7111_MM.xlsm").Worksheets("ASX_Data").Range("H12").Resize(copyRange.Rows.Count, copyRange.Columns.Count)
pasteRange.Value = copyRange.Value
Application.Calculation = xlCalculationAutomatic
Workbooks("abcd.xlsx").Close SaveChanges:=False
Range("A1").Select
MsgBox ("Data has been Updated and ABCD.xlsm has been Closed." & vbCrLf & vbCrLf & "Pls delete (or rename)it." & vbCrLf & vbCrLf & "If you don't delete (or rename), it may cause a problem with tomorrows download")
End Sub
We now add a date to the name, so today's file is called abcd_20221017.xlsm (so we have added an underscore and the current date to the end of the file name. so yesterday's file was called abcd_20221016.xlsm.
I'm hoping to adjust the following code so it works with any file named abcd regardless of what comes after it. The file type will always be .xlsm
Would appreciate any help
Sub Copy_PasteSpecial_Method()
If Workbook_Is_Opened("abcd.xlsx") = False Then
MsgBox "Please open File ABCD.xlsm for this operation to occur.", vbCritical, "Try Again After Opening Workbook"
Exit Sub
End If
If Workbook_Is_Opened("Journal_7111_MM.xlsm") = False Then
MsgBox "Please open [Journal_7111_MM] for this operation to occur.", vbCritical, "Try Again After Opening Workbook"
Exit Sub
End If
Dim copyRange As Range
Set copyRange = Workbooks("abcd.xlsx").Worksheets("Sheet1").Range("A1:IZ2121")
Dim pasteRange As Range
Set pasteRange = Workbooks("Journal_7111_MM.xlsm").Worksheets("engine").Range("A1:IZ2121")
Application.Calculation = xlCalculationManual
pasteRange.Value = copyRange.Value
Set copyRange = Workbooks("abcd.xlsx").Worksheets("Sheet2").Range("A1:AXG2110")
Set pasteRange = Workbooks("Journal_7111_MM.xlsm").Worksheets("ASX_Data").Range("H12").Resize(copyRange.Rows.Count, copyRange.Columns.Count)
pasteRange.Value = copyRange.Value
Application.Calculation = xlCalculationAutomatic
Workbooks("abcd.xlsx").Close SaveChanges:=False
Range("A1").Select
MsgBox ("Data has been Updated and ABCD.xlsm has been Closed." & vbCrLf & vbCrLf & "Pls delete (or rename)it." & vbCrLf & vbCrLf & "If you don't delete (or rename), it may cause a problem with tomorrows download")
End Sub