Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

VBAでの配列

More than 5 years have passed since last update.

概要

VBAで配列を扱う場合のメモ

ソース

末尾に追加

Sub main()
    ' Array()は、Variant型になります
    Dim a As Variant
    a = Array(1, 2, 3)
    b = 4

    ' 要素数を拡大します。
    ' Preserveを付けないとデータが消えます。
    '   Redim - 要素数の変更
    '   UBound - 要素数の取得
    ReDim Preserve a(UBound(a) + 1)
    a(UBound(a)) = b
End Sub

簡単なマージ

マージ関数が見つからないので、簡単な結合方法

Sub sample_push()
    ' Array()は、Variant型になります
    Dim a As Variant
    a = Array(1, 2, 3)
    b = Array(4, 5, 6)

    ' splitを利用して、配列を生成します。
    ' 分割文字は、場合に合わせて変更します。
    c = Split(Join(a, "@") & "@" & Join(b, "@"), "@")
End Sub
YamasakiKenta
特にありません。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away