Materi Perkuliahan

Memutarkan Objek dengan Menggunakan VBA Excel

Dipublikasikan pada : 7 Februari 2021.

Sub trigonometri()
Dim lembar As Worksheet
Set lembar = Worksheets(5)
a = 4 * Application.WorksheetFunction.Atan2(1, 1)
Range(“B1”).Formula = Tan(a * Range(“A1”) / 180)
lembar.Shapes(“segitiga”).Height = Range(“C1”) * Sin(a * Range(“A1”) / 180)
lembar.Shapes(“segitiga”).Width = 2 * lembar.Shapes(“segitiga”).Height / (Range(“B1”))
End Sub

Sub berputar()
Dim lembar As Worksheet
Set lembar = Worksheets(6)
Application.OnTime Now + TimeValue(“00:00:01”), “berputar”
lembar.Shapes(“papan”).TextFrame2.TextRange.Text = lembar.Shapes(“papan”).TextFrame2.TextRange.Text + 1
lembar.Shapes(“segitiga”).Rotation = lembar.Shapes(“papan”).TextFrame2.TextRange.Text * 10
Range(“I4”) = lembar.Shapes(“segitiga”).Left
Range(“I5”) = lembar.Shapes(“segitiga”).Top
End Sub
Sub berhenti()
On Error Resume Next
Application.OnTime Now + TimeValue(“00:00:01”), “berputar”, , False
End Sub