Hi guys,
I´ve written a code in VBA in which I created several shapes that represents streets, cars, then I move these shapes around according to a traffic system.
I´ve had problem using the index of each shapes (index kept rising), so I have named each one.
The problem is that each time that I simulate my code, I have to give new names to my shapes otherwise the commands won´t work.
My code first builts a cenario, then moves the shapes around. Sometimes I can simulate it more than once, and sometimes I need to rename the shapes to run it again. Its totally random!
Here is my code: The first macro generates the scenario. The second makes the cars movement. Note that there should be 6 cars (shapes) going up but they stop working for some reason unless I rename them.
Sub cenario()
Application.ScreenUpdating = True
ActiveSheet.Shapes.SelectAll
Selection.Delete
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 135, 302, 800, 30). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "1"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 135, 360, 800, 30). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "2"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 280, 202, 30, 280). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "3"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 500, 202, 30, 280). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "4"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 720, 202, 30, 280). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "5"
ActiveSheet.Shapes.AddShape(msoShapeFlowchartProcess, 135, 340, 800, 3). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.Brightness = -0.25
End With
Selection.Name = "6"
ActiveSheet.Shapes.AddShape(msoShapeFlowchartProcess, 135, 350, 800, 3). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.Brightness = -0.25
End With
Selection.Name = "7"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 289.5, 285, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 180
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "8"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 510, 285, 10, 15) _
.Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "9"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 730, 285, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 180
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "10"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 289.5, 390, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 180
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "11"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 510, 390, 10, 15) _
.Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "12"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 730, 390, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 180
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "13"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 315, 310, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation -90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "14"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 535, 310, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation -90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "15"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 755, 310, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation -90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "16"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 265, 367, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "17"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 485, 367, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "18"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 710, 367, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "19"
' Primeiro semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 265, 335, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "20"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 270.5, 335, 270.5, 346). _
Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoFalse
.Weight = 2.25
End With
Selection.Name = "21"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 265.7894488189, 340.5, _
276.7894488189, 340.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "22"
' Segundo semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 485, 335, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "23"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 490.5, 335, 490.5, 346). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "24"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 484.2682677165, 340.5, _
495.2682677165, 340.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "25"
' Terceiro semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 705, 335, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "26"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 710.5, 335, 710.5, 346). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "27"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 703.9755905512, 340.5, _
714.9755905512, 340.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "28"
' Quarto semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 315, 346, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "29"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 320.5, 346, 320.5, 357). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "30"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 314.5609448819, 351.5, _
325.5609448819, 351.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "31"
' Quinto semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 535, 346, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "32"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 540.5, 346, 540.5, 357). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "33"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 534.1951181102, 351.5, _
545.1951181102, 351.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "34"
' Sexto semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 755, 346, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "35"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 760.5, 346, 760.5, 357). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "36"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 753.9024409449, 351.5, _
764.9024409449, 351.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "37"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "and1"
Selection.Visible = msoTrue
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi2"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi3"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi4"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi5"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi6"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 205, 15, 15). _
Select
Selection.Name = "v7"
Selection.Visible = msoTrue
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 245, 15, 15). _
Select
Selection.Name = "v8"
Selection.Visible = msoTrue
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 285, 15, 15). _
Select
Selection.Name = "v9"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 325, 15, 15). _
Select
Selection.Name = "v10"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 365, 15, 15). _
Select
Selection.Name = "48"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 405, 15, 15). _
Select
Selection.Name = "49"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "50"
Selection.Visible = msoTrue
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "51"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "52"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "53"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "54"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "55"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 140, 337, 40, 8). _
Select
Selection.Name = "veelete"
Selection.Visible = msoTrue
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(200, 100, 200)
End Sub
Sub verde_vertical()
ActiveSheet.Shapes("8").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 255, 0)
ActiveSheet.Shapes("11").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 255, 0)
i = 1
Do While 1
DoEvents
If i > 200 Then
ActiveSheet.Shapes("gabi6").Visible = msoTrue
ActiveSheet.Shapes("gabi6").Top = ActiveSheet.Shapes("gabi6").Top - 1
ActiveSheet.Shapes("gabi5").Top = ActiveSheet.Shapes("gabi5").Top - 1
ActiveSheet.Shapes("gabi4").Top = ActiveSheet.Shapes("gabi4").Top - 1
ActiveSheet.Shapes("gabi3").Top = ActiveSheet.Shapes("gabi3").Top - 1
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
ElseIf i > 160 Then
ActiveSheet.Shapes("gabi5").Visible = msoTrue
ActiveSheet.Shapes("gabi5").Top = ActiveSheet.Shapes("gabi5").Top - 1
ActiveSheet.Shapes("gabi4").Top = ActiveSheet.Shapes("gabi4").Top - 1
ActiveSheet.Shapes("gabi3").Top = ActiveSheet.Shapes("gabi3").Top - 1
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
ElseIf i > 120 Then
ActiveSheet.Shapes("gabi4").Visible = msoTrue
ActiveSheet.Shapes("gabi4").Top = ActiveSheet.Shapes("gabi4").Top - 1
ActiveSheet.Shapes("gabi3").Top = ActiveSheet.Shapes("gabi3").Top - 1
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
ElseIf i > 80 Then
ActiveSheet.Shapes("gabi3").Visible = msoTrue
ActiveSheet.Shapes("gabi3").Top = ActiveSheet.Shapes("gabi3").Top - 1
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
ElseIf i > 40 Then
ActiveSheet.Shapes("gabi2").Visible = msoTrue
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
End If
ActiveSheet.Shapes("and1").Top = ActiveSheet.Shapes("and1").Top - 1
If Round(ActiveSheet.Shapes("and1").Top) = 205 Then ActiveSheet.Shapes("and1").Top = 463
If Round(ActiveSheet.Shapes("gabi2").Top) = 205 Then ActiveSheet.Shapes("gabi2").Top = 463
If Round(ActiveSheet.Shapes("gabi3").Top) = 205 Then ActiveSheet.Shapes("gabi3").Top = 463
If Round(ActiveSheet.Shapes("gabi4").Top) = 205 Then ActiveSheet.Shapes("gabi4").Top = 463
If Round(ActiveSheet.Shapes("gabi5").Top) = 205 Then ActiveSheet.Shapes("gabi5").Top = 463
If Round(ActiveSheet.Shapes("gabi6").Top) = 205 Then ActiveSheet.Shapes("gabi6").Top = 463
i = i + 1
If i > 800 Then Exit Sub
Loop
Application.ScreenUpdating = True
End Sub
I´ve written a code in VBA in which I created several shapes that represents streets, cars, then I move these shapes around according to a traffic system.
I´ve had problem using the index of each shapes (index kept rising), so I have named each one.
The problem is that each time that I simulate my code, I have to give new names to my shapes otherwise the commands won´t work.
My code first builts a cenario, then moves the shapes around. Sometimes I can simulate it more than once, and sometimes I need to rename the shapes to run it again. Its totally random!
Here is my code: The first macro generates the scenario. The second makes the cars movement. Note that there should be 6 cars (shapes) going up but they stop working for some reason unless I rename them.
Sub cenario()
Application.ScreenUpdating = True
ActiveSheet.Shapes.SelectAll
Selection.Delete
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 135, 302, 800, 30). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "1"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 135, 360, 800, 30). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "2"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 280, 202, 30, 280). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "3"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 500, 202, 30, 280). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "4"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 720, 202, 30, 280). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.Brightness = -0.349999994
End With
Selection.ShapeRange.Line.Visible = msoFalse
Selection.Name = "5"
ActiveSheet.Shapes.AddShape(msoShapeFlowchartProcess, 135, 340, 800, 3). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.Brightness = -0.25
End With
Selection.Name = "6"
ActiveSheet.Shapes.AddShape(msoShapeFlowchartProcess, 135, 350, 800, 3). _
Select
With Selection.ShapeRange.Fill
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.Brightness = -0.25
End With
Selection.Name = "7"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 289.5, 285, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 180
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "8"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 510, 285, 10, 15) _
.Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "9"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 730, 285, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 180
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "10"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 289.5, 390, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 180
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "11"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 510, 390, 10, 15) _
.Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "12"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 730, 390, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 180
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "13"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 315, 310, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation -90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "14"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 535, 310, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation -90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "15"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 755, 310, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation -90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "16"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 265, 367, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "17"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 485, 367, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "18"
ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTriangle, 710, 367, 10, 15) _
.Select
Selection.ShapeRange.IncrementRotation 90
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
Selection.Name = "19"
' Primeiro semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 265, 335, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "20"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 270.5, 335, 270.5, 346). _
Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoFalse
.Weight = 2.25
End With
Selection.Name = "21"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 265.7894488189, 340.5, _
276.7894488189, 340.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "22"
' Segundo semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 485, 335, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "23"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 490.5, 335, 490.5, 346). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "24"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 484.2682677165, 340.5, _
495.2682677165, 340.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "25"
' Terceiro semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 705, 335, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "26"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 710.5, 335, 710.5, 346). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "27"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 703.9755905512, 340.5, _
714.9755905512, 340.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "28"
' Quarto semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 315, 346, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "29"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 320.5, 346, 320.5, 357). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "30"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 314.5609448819, 351.5, _
325.5609448819, 351.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "31"
' Quinto semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 535, 346, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "32"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 540.5, 346, 540.5, 357). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "33"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 534.1951181102, 351.5, _
545.1951181102, 351.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "34"
' Sexto semáforo VLT
ActiveSheet.Shapes.AddShape(msoShapeOval, 755, 346, 11, 11).Select
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset8
Selection.Name = "35"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 760.5, 346, 760.5, 357). _
Select
With Selection.ShapeRange.Line
.Visible = msoFalse
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Weight = 2.25
End With
Selection.Name = "36"
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 753.9024409449, 351.5, _
764.9024409449, 351.5).Select
With Selection.ShapeRange.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.Visible = msoTrue
.Weight = 2.25
End With
Selection.Name = "37"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "and1"
Selection.Visible = msoTrue
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi2"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi3"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi4"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi5"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 288, 463, 15, 15). _
Select
Selection.Name = "gabi6"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 205, 15, 15). _
Select
Selection.Name = "v7"
Selection.Visible = msoTrue
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 245, 15, 15). _
Select
Selection.Name = "v8"
Selection.Visible = msoTrue
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 285, 15, 15). _
Select
Selection.Name = "v9"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 325, 15, 15). _
Select
Selection.Name = "v10"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 365, 15, 15). _
Select
Selection.Name = "48"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 508, 405, 15, 15). _
Select
Selection.Name = "49"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "50"
Selection.Visible = msoTrue
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "51"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "52"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "53"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "54"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 728, 463, 15, 15). _
Select
Selection.Name = "55"
Selection.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 140, 337, 40, 8). _
Select
Selection.Name = "veelete"
Selection.Visible = msoTrue
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(200, 100, 200)
End Sub
Sub verde_vertical()
ActiveSheet.Shapes("8").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 255, 0)
ActiveSheet.Shapes("11").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 255, 0)
i = 1
Do While 1
DoEvents
If i > 200 Then
ActiveSheet.Shapes("gabi6").Visible = msoTrue
ActiveSheet.Shapes("gabi6").Top = ActiveSheet.Shapes("gabi6").Top - 1
ActiveSheet.Shapes("gabi5").Top = ActiveSheet.Shapes("gabi5").Top - 1
ActiveSheet.Shapes("gabi4").Top = ActiveSheet.Shapes("gabi4").Top - 1
ActiveSheet.Shapes("gabi3").Top = ActiveSheet.Shapes("gabi3").Top - 1
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
ElseIf i > 160 Then
ActiveSheet.Shapes("gabi5").Visible = msoTrue
ActiveSheet.Shapes("gabi5").Top = ActiveSheet.Shapes("gabi5").Top - 1
ActiveSheet.Shapes("gabi4").Top = ActiveSheet.Shapes("gabi4").Top - 1
ActiveSheet.Shapes("gabi3").Top = ActiveSheet.Shapes("gabi3").Top - 1
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
ElseIf i > 120 Then
ActiveSheet.Shapes("gabi4").Visible = msoTrue
ActiveSheet.Shapes("gabi4").Top = ActiveSheet.Shapes("gabi4").Top - 1
ActiveSheet.Shapes("gabi3").Top = ActiveSheet.Shapes("gabi3").Top - 1
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
ElseIf i > 80 Then
ActiveSheet.Shapes("gabi3").Visible = msoTrue
ActiveSheet.Shapes("gabi3").Top = ActiveSheet.Shapes("gabi3").Top - 1
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
ElseIf i > 40 Then
ActiveSheet.Shapes("gabi2").Visible = msoTrue
ActiveSheet.Shapes("gabi2").Top = ActiveSheet.Shapes("gabi2").Top - 1
End If
ActiveSheet.Shapes("and1").Top = ActiveSheet.Shapes("and1").Top - 1
If Round(ActiveSheet.Shapes("and1").Top) = 205 Then ActiveSheet.Shapes("and1").Top = 463
If Round(ActiveSheet.Shapes("gabi2").Top) = 205 Then ActiveSheet.Shapes("gabi2").Top = 463
If Round(ActiveSheet.Shapes("gabi3").Top) = 205 Then ActiveSheet.Shapes("gabi3").Top = 463
If Round(ActiveSheet.Shapes("gabi4").Top) = 205 Then ActiveSheet.Shapes("gabi4").Top = 463
If Round(ActiveSheet.Shapes("gabi5").Top) = 205 Then ActiveSheet.Shapes("gabi5").Top = 463
If Round(ActiveSheet.Shapes("gabi6").Top) = 205 Then ActiveSheet.Shapes("gabi6").Top = 463
i = i + 1
If i > 800 Then Exit Sub
Loop
Application.ScreenUpdating = True
End Sub