День добрый, столкнулся с проблемой присвоения определенному колонтитулу определенного значения записанного в определенной ячейке непечатной области. Попробовал написать макрос, но знаний не хватило, приведенный ниже.
Private Sub Worksheet_Kolontit()
Dim A, B, C, D, E, F, G, H, I
Application.EnableEvents = False
With ActiveSheet.PageSetup
A = Range("п.1.6").Value
B = Range("п. 2.2").Value
С = Range("Программа").Value
D = Range("Программа_2").Value
E = Range("перечень").Value
F = Range("Акт").Value
G = Range("Приказ").Value
H = Range("Письмо").Value
I = Range("Последний_лист").Value
.RightFooter = "&P"
If .RightFooter = 1 Then .RightFooter = ""
If .RightFooter = 2 Then .RightFooter = A
If .RightFooter = 3 Then .RightFooter = B
If .RightFooter = 4 Then .RightFooter = C
If .RightFooter = 5 Then .RightFooter = D
If .RightFooter = 6 Then .RightFooter = E
If .RightFooter = 7 Then .RightFooter = F
If .RightFooter = 8 Then .RightFooter = G
If .RightFooter = 9 Then .RightFooter = H
If .RightFooter = 10 Then .RightFooter = I
End With
Application.EnableEvents = True
End Sub
Помогите разобраться.
Private Sub Worksheet_Kolontit()
Dim A, B, C, D, E, F, G, H, I
Application.EnableEvents = False
With ActiveSheet.PageSetup
A = Range("п.1.6").Value
B = Range("п. 2.2").Value
С = Range("Программа").Value
D = Range("Программа_2").Value
E = Range("перечень").Value
F = Range("Акт").Value
G = Range("Приказ").Value
H = Range("Письмо").Value
I = Range("Последний_лист").Value
.RightFooter = "&P"
If .RightFooter = 1 Then .RightFooter = ""
If .RightFooter = 2 Then .RightFooter = A
If .RightFooter = 3 Then .RightFooter = B
If .RightFooter = 4 Then .RightFooter = C
If .RightFooter = 5 Then .RightFooter = D
If .RightFooter = 6 Then .RightFooter = E
If .RightFooter = 7 Then .RightFooter = F
If .RightFooter = 8 Then .RightFooter = G
If .RightFooter = 9 Then .RightFooter = H
If .RightFooter = 10 Then .RightFooter = I
End With
Application.EnableEvents = True
End Sub
Помогите разобраться.