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
1
Help us understand the problem. What is going on with this article?
@tnaga77

VBAで配列をつくるには

More than 1 year has passed since last update.

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
1
Help us understand the problem. What is going on with this article?
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
tnaga77

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?