Hi Folks,
The code placed below is throwing an error ( "Run-time error 9 Subscript out of range") on the following lines in the code placed at the end of this post:
Set WrkBk0 = Workbooks(Wk0)
Set WrkBk1 = Workbooks(Wk1)
Tried but failed to figure out the reason.
Can somebody help please?
Thanks in advance
Regards,
Amber
-------------------------------------------------------------------------------------------------------------------------------------------
Sub Topfive()
Dim WrkBk0 As Workbook
Dim WrkBk1 As Workbook
Dim WrkSt1 As Worksheet
Dim WrkSt2 As Worksheet
Dim WrkSt3 As Worksheet
Dim Wk0, Wk1 As String
Dim M1 As String
Dim M0 As String
Dim Y0, Y1 As Integer
Dim D As Variant
M0 = Format(DateAdd("M", -2, Date), "mmm")
M1 = Format(DateAdd("M", -1, Date), "mmm")
Y0 = Format(DateAdd("m", -1, Date), "yy")
Y1 = Format(DateAdd("m", -2, Date), "yy")
Wk0 = "Performance Master_" & M0 & " " & Y0 & ".xlsm"
Wk1 = "Performance Master_" & M1 & " " & Y1 & ".xlsm"
Set WrkBk0 = Workbooks(Wk0)
Set WrkBk1 = Workbooks(Wk1)
Set WrkSt1 = Sheets("Performance Summay")
Set WrkSt2 = Sheets("Sheet1")
Set WrkSt3 = Sheets("Performance Summary")
End Sub
------------------------------------------------------------------------------------------------------------------------------------------
Bookmarks