1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

2次元配列をシートに貼り付けする

Posted at
Sub PasteArrayToSheet()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("貼り付け先のシート名") ' 貼り付け先のシート名を設定
    
    Dim arr As Variant
    arr = ExtractRowsStartingWithOne() ' 関数から2次元配列を取得
    
    If Not IsEmpty(arr) Then
        Dim startCell As Range
        Set startCell = ws.Range("貼り付け開始セル") ' 例: "A1"
        
        ' 貼り付ける範囲を計算
        Dim endRow As Long
        endRow = startCell.Row + UBound(arr, 1) - 1
        
        Dim endColumn As Long
        endColumn = startCell.Column + UBound(arr, 2) - 1
        
        Dim endCell As Range
        Set endCell = ws.Cells(endRow, endColumn)
        
        ' 計算された範囲に配列の内容を貼り付け
        ws.Range(startCell, endCell).Value = arr
    End If
End Sub
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?