Animation Of The Colors With Excel VBA Codes




           Excel animation with voice and music prepared with Excel VBA codes to learn Spanish colors.

When clicked on the color circles, the animation of clicked color starts A 3D cylinder was selected as the animation item.At the end of the animation, the name of the color is played and a child laughing effect is played using playing function. Spanish colours were used as example colors in the template.

 The function that generates moving :
Sub basla()
 m = 0
    For i = 1 To 90
      Selection.ShapeRange.ThreeD.RotationY = m
      m = m - 1
    DoEvents
    Next i
        For i = 1 To 180
      Selection.ShapeRange.ThreeD.RotationY = m
      m = m + 1
      DoEvents
    Next i
        For i = 1 To 90
      Selection.ShapeRange.ThreeD.RotationY = m
      m = m - 1
      DoEvents
    Next i
        For i = 1 To 90
      Selection.ShapeRange.ThreeD.RotationX = m
      m = m - 1
      DoEvents
    Next i
       For i = 1 To 180
      Selection.ShapeRange.ThreeD.RotationX = m
      m = m + 1
      DoEvents
    Next i
        For i = 1 To 90
      Selection.ShapeRange.ThreeD.RotationX = m
      m = m - 1
      DoEvents
    Next i
    End Sub



Read more ...

Excel VBA Dictionary (Catalog) Form

Excel VBA Dictionary Userform




        It can be used as an application such as dictionary, index.
For example, we entered the names of the vitamins to column A and entered descriptions of vitamins to column B.
The data in column A of the sheet is filled to the combobox on the userform.

The value corresponding to the item selected from the combobox is fetched from the column B and displayed on label under the combobox.

The used codes to increase the width of the UserForm:
Private Sub CommandButton4_Click()
Dim X, d, yuk As Integer
If CommandButton4.Caption = "8" And Data_Form.Width = 410 Then
For d = 1 To 158
DoEvents
yuk = 410
Data_Form.Width = yuk - d
Next
ComboBoxTopics.Enabled = True
ComboBoxTopics.ListIndex = 0
CommandButton4.Caption = "9"
Exit Sub
End If
If CommandButton4.Caption = "9" And Data_Form.Width = 252 Then
For X = 1 To 158
DoEvents
yuk = 252
Data_Form.Width = yuk + X
Next
ComboBoxTopics.Enabled = False
CommandButton4.Caption = "8"
End If
End Sub


Read more ...

Excel VBA Animation Examples

Excel Animations That Created With VBA Codes     


         Simple and instructive animations for those who want to learn the Excel programming. Macro codes of the animations can be viewed in the workbooks.


⇨ Generally ,the shapes in the worksheet are moved with Vba codes and loops.

excel animations


excel vba animation sample
Let's review an VBA animation sample :


🔊 This Excel animation includes an .wav file to play audio during action.


excel animation with audio

The codes that provide action when the start button is clicked:
Sub Baslat()
SesDosyasi = ThisWorkbook.Path & Application.PathSeparator & "ses1.wav"
Dim sh As Shape
Dim s1 As Worksheet
Dim r As Range
Dim konumX As Double
Dim konumY As Double

Dur = False

Set s1 = ThisWorkbook.Worksheets("ANIMA")
Set sh = s1.Shapes("excelvba.net")
Set r = s1.Range("F7")
If Not IsNumeric(s1.Range("HIZ")) Then Hiz = 10 Else Hiz = s1.Range("HIZ")
If Hiz <= 0 Or Hiz > 50 Then
Hiz = 1
s1.Range("HIZ") = 10
End If
If Not IsNumeric(s1.Range("ACI")) Then Aci = 0 Else Aci = s1.Range("ACI")
If Aci < 0 Or Aci > 360 Then
Aci = 0
s1.Range("ACI") = 0
End If

radyan = Aci * pi / 180
konumX = sh.Left
konumY = sh.Top
Do
'Calculate position konumX = konumX + 3 * Cos(radyan)
konumY = konumY + 3 * Sin(radyan)

'Did the shape hit the right edge?
If (konumX + sh.Width >= r.Left + r.Width) Then
konumX = r.Left + r.Width - sh.Width
radyan = pi - radyan
sh.Adjustments(1) = 0.718
sndPlaysound SesDosyasi, 1
End If

'Did the shape hit the left edge?
If (konumX <= r.Left) Then
konumX = r.Left
radyan = pi - radyan
sh.Adjustments(1) = 0.718
sndPlaysound SesDosyasi, 1
End If

'Did the shape hit the up ?
If (konumY <= r.Top) Then
konumY = r.Top
radyan = radyan * -1
sh.Adjustments(1) = 0.718
sndPlaysound SesDosyasi, 1
End If

'Did the shape hit the bottom ?
If (konumY + sh.Height >= r.Top + r.Height) Then
konumY = r.Top + r.Height - sh.Width
radyan = -1 * radyan
sh.Adjustments(1) = 0.718
sndPlaysound SesDosyasi, 1
End If

sh.Left = konumX
sh.Top = konumY
sh.Rotation = sh.Rotation + 3
sh.Adjustments(1) = sh.Adjustments(1) + 0.002
Bekle (50 / Hiz)
Loop Until Dur
End Sub

Lines starting with apostrophes ( ' ) in VBA codes are comments.
excel vba animation action excel movement


Read more ...