18 VBA Advanced (Array)

preview_player
Показать описание
18 VBA Advanced - Arrays (Creating, Amending), Multidimensional
Follow-up of VBA Beyond Basics and VBA for EveryOne Series

Topics in this Video:
Arrays Creating, Editing
Items and Elements
Multidimensional

Code:
Sub vDaArray()

Dim vMyArray
'Elements
vMyArray = Array(1, 2, 3, 4, 5)

For vMyLoop = 1 To 5
MsgBox (vMyArray(vMyLoop))
Next vMyLoop

End Sub
Sub vDaArrayAdd()

Dim vMyArray
'Elements
vMyArray = Array(1, 2, 3, 4, 5)

ReDim vMyArray(6)
vMyArray(5) = "Hello World"

For vMyLoop = 0 To 5
MsgBox (vMyArray(vMyLoop))
Next vMyLoop

End Sub

Sub vDaArrayDelete()

Dim vMyArray
'Elements
vMyArray = Array(1, 2, 3, 4, 5)

vMyArray(3) = ""


For vMyLoop = 0 To 4
MsgBox (vMyArray(vMyLoop))
Next vMyLoop

End Sub

Sub vDaArrayCounter()

Dim vMyArray

'Elements
vMyArray = Array(1, 2, 3, 4, 5)

MsgBox (UBound(vMyArray))
MsgBox (LBound(vMyArray))

End Sub

Sub vDaArrayReadRange()

Dim vMyArray

'Elements
vMyArray = Range("A1:A3").Value
'Range("B1:B3").Value = vMyArray

For vMyLoop = 1 To 3
MsgBox (vMyArray(vMyLoop, 1))
Next vMyLoop

End Sub
Sub vDaArrayWriteRange()

Dim vMyArray

'Elements
vMyArray = Range("A1:A3").Value
Range("B1:B3").Value = vMyArray
Range("D1").Value = vMyArray(2, 1)


End Sub
Рекомендации по теме