Sub Sample()
Dim a(10) As Variant, b(10, 1 To 5) As Variant, c As Variant
c = Array(1, 2, 3)
MsgBox UBound(a)
MsgBox UBound(b, 2)
MsgBox UBound(c)
End Sub
Sub Sample()
Dim buf As String, n As Long
ReDim Files(0) ''動的配列を宣言します
buf = Dir("C:\Windows\*.*")
Do While buf <> ""
n = UBound(Files) ''現在の大きさ(要素数)を調べます
ReDim Preserve Files(n + 1) ''動的配列の大きさを1つ増やします
Files(n + 1) = buf ''ファイル名を格納します
buf = Dir()
Loop
MsgBox UBound(Files) - 1 & "個あります" ''動的配列の大きさ(要素数)を調べます
End Sub
Sub Sample()
Dim buf As String, cnt As Long, tmp As Variant, i As Long
Open "C:\Sample.csv" For Input As #1
Do Until EOF(1)
Line Input #1, buf
tmp = Split(buf, ",")
cnt = cnt + 1
For i = 0 To UBound(tmp)
Cells(cnt, i + 1) = tmp(i)
Next i
Loop
Close #1
End Sub
Sub Sample()
Dim Files As Variant
ChDrive "C"
ChDir "C:\Tmp"
Files = Application.GetOpenFilename(MultiSelect:=True)
If Not IsArray(Files) Then Exit Sub
MsgBox UBound(Files) & "個が選択されました"
End Sub