Простите код, все еще изучая VBA, делая так долго.
Вчера этот макрос работал без проблем, но сегодня он выдает ошибку 91 в строке:
HiddenCell7.Value = "=CELL(""address""," & TodaysDateP7.Address(External:=True) & ")"
Я не могу понять, в чем проблема.
Код ниже:
Private Sub Workbook_Open()
Dim Date0 As Date
Dim Date1 As Date
Dim Date2 As Date
Dim Date3 As Date
Dim Date4 As Date
Dim Date5 As Date
Dim Date6 As Date
Dim TodaysDateP1 As Range
Dim TodaysDateP2 As Range
Dim TodaysDateP3 As Range
Dim TodaysDateP4 As Range
Dim TodaysDateP5 As Range
Dim TodaysDateP6 As Range
Dim TodaysDateP7 As Range
Dim HiddenCell1 As Range
Dim HiddenCell2 As Range
Dim HiddenCell3 As Range
Dim HiddenCell4 As Range
Dim HiddenCell5 As Range
Dim HiddenCell6 As Range
Dim HiddenCell7 As Range
Date0 = Date
Date1 = DateAdd("d", 1, Date)
Date2 = DateAdd("d", 2, Date)
Date3 = DateAdd("d", 3, Date)
Date4 = DateAdd("d", 4, Date)
Date5 = DateAdd("d", 5, Date)
Date6 = DateAdd("d", 6, Date)
Set TodaysDateP1 = Range("April2020").Find(Date0)
Set TodaysDateP2 = Range("April2020").Find(Date1)
Set TodaysDateP3 = Range("April2020").Find(Date2)
Set TodaysDateP4 = Range("April2020").Find(Date3)
Set TodaysDateP5 = Range("April2020").Find(Date4)
Set TodaysDateP6 = Range("April2020").Find(Date5)
Set TodaysDateP7 = Range("April2020").Find(Date6)
Set HiddenCell1 = Sheets("W").Range("C15")
Set HiddenCell2 = Sheets("W").Range("H15")
Set HiddenCell3 = Sheets("W").Range("M15")
Set HiddenCell4 = Sheets("W").Range("R15")
Set HiddenCell5 = Sheets("W").Range("C33")
Set HiddenCell6 = Sheets("W").Range("H33")
Set HiddenCell7 = Sheets("W").Range("M33")
HiddenCell1.Value = "=CELL(""address""," & TodaysDateP1.Address(External:=True) & ")"
HiddenCell2.Value = "=CELL(""address""," & TodaysDateP2.Address(External:=True) & ")"
HiddenCell3.Value = "=CELL(""address""," & TodaysDateP3.Address(External:=True) & ")"
HiddenCell4.Value = "=CELL(""address""," & TodaysDateP4.Address(External:=True) & ")"
HiddenCell5.Value = "=CELL(""address""," & TodaysDateP5.Address(External:=True) & ")"
HiddenCell6.Value = "=CELL(""address""," & TodaysDateP6.Address(External:=True) & ")"
HiddenCell7.Value = "=CELL(""address""," & TodaysDateP7.Address(External:=True) & ")"
End Sub
Большое спасибо за вашу помощь!