Help us understand the problem. What is going on with this article?

VBAで配列をつくるには

VBAで配列をつくるには

VBAを学ぶ必要に迫られたので記述

Sub Sample()
    Dim A As Variant
    Dim ObjectSheetA As Worksheet

    Set ObjectSheetA = Worksheets("c01") 'シートを指定
    Dim min_raw As Variant
    Dim max_raw As Variant
    Dim min_col As Variant
    Dim max_col As Variant

    '範囲指定
    min_raw = 1
    max_raw = 981
    min_col = 1
    max_col = 9
    'Debug.Print (max_col) 'デバッグ用

    'GetArray関数で配列を作成
    A = GetArray(min_raw, min_col, max_raw, max_col, ObjectSheetA)
    'MsgBox "A(100, 1) = " & A(100, 1) & vbCr 'デバッグ用

    For i = min_raw To max_raw
    Debug.Print (A(i, 2))
    Next

End Sub


'配列を作成する関数
'引数: 5つ(Variant 4つ, Worksheet 1つ)
'返り値: Tablevalue(Variant)
Function GetArray(min_raw As Variant, min_col As Variant, max_raw As Variant, max_col As Variant, ObjectSheet As Worksheet)
    Dim TableValue As Variant
    TableValue = ObjectSheet.Cells(min_raw, min_col).Resize(max_raw, max_col).Value
    GetArray = TableValue
End Function
tnaga77
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした