Работа с автофигурами в ВБА
посмотрите пожалуста на код и если можете дайте совет по оптимизации, просто в структуре:
If nom <> ActiveSheet.Shapes("autoforma1").Name Then
ActiveSheet.Shapes("autoforma1").Rotation = 0
End If
строчку ActiveSheet.Shapes("autoforma1").Name можно на чтото заменить? ато кажетча что пишу 2 раза имя автофигуры. есть какоето генерическое имя для автофигур кроме того что мы ему присвоем?
Код:
Sub Rote_Autoforma1()
Call Reset("autoforma1")
If ActiveSheet.Shapes("autoforma1").Rotation = 180 Then
ActiveSheet.Shapes("autoforma1").Rotation = 0
Else
ActiveSheet.Shapes("autoforma1").Rotation = 180
End If
End Sub
Sub Rote_Autoforma2()
Call Reset("autoforma2")
If ActiveSheet.Shapes("autoforma2").Rotation = 180 Then
ActiveSheet.Shapes("autoforma2").Rotation = 0
Else
ActiveSheet.Shapes("autoforma2").Rotation = 180
End If
End Sub
Sub Rote_Autoforma3()
Call Reset("autoforma3")
If ActiveSheet.Shapes("autoforma3").Rotation = 180 Then
ActiveSheet.Shapes("autoforma3").Rotation = 0
Else
ActiveSheet.Shapes("autoforma3").Rotation = 180
End If
End Sub
Sub Reset(nom As String)
If nom <> ActiveSheet.Shapes("autoforma1").Name Then
ActiveSheet.Shapes("autoforma1").Rotation = 0
End If
If nom <> ActiveSheet.Shapes("autoforma2").Name Then
ActiveSheet.Shapes("autoforma2").Rotation = 0
End If
If nom <> ActiveSheet.Shapes("autoforma3").Name Then
ActiveSheet.Shapes("autoforma3").Rotation = 0
End If
End Sub
посмотрите пожалуста на код и если можете дайте совет по оптимизации, просто в структуре:
If nom <> ActiveSheet.Shapes("autoforma1").Name Then
ActiveSheet.Shapes("autoforma1").Rotation = 0
End If
строчку ActiveSheet.Shapes("autoforma1").Name можно на чтото заменить? ато кажетча что пишу 2 раза имя автофигуры. есть какоето генерическое имя для автофигур кроме того что мы ему присвоем?
Код:
Sub Rote_Autoforma1()
Call Reset("autoforma1")
If ActiveSheet.Shapes("autoforma1").Rotation = 180 Then
ActiveSheet.Shapes("autoforma1").Rotation = 0
Else
ActiveSheet.Shapes("autoforma1").Rotation = 180
End If
End Sub
Sub Rote_Autoforma2()
Call Reset("autoforma2")
If ActiveSheet.Shapes("autoforma2").Rotation = 180 Then
ActiveSheet.Shapes("autoforma2").Rotation = 0
Else
ActiveSheet.Shapes("autoforma2").Rotation = 180
End If
End Sub
Sub Rote_Autoforma3()
Call Reset("autoforma3")
If ActiveSheet.Shapes("autoforma3").Rotation = 180 Then
ActiveSheet.Shapes("autoforma3").Rotation = 0
Else
ActiveSheet.Shapes("autoforma3").Rotation = 180
End If
End Sub
Sub Reset(nom As String)
If nom <> ActiveSheet.Shapes("autoforma1").Name Then
ActiveSheet.Shapes("autoforma1").Rotation = 0
End If
If nom <> ActiveSheet.Shapes("autoforma2").Name Then
ActiveSheet.Shapes("autoforma2").Rotation = 0
End If
If nom <> ActiveSheet.Shapes("autoforma3").Name Then
ActiveSheet.Shapes("autoforma3").Rotation = 0
End If
End Sub