0
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.

複数列を縦に並べる関数

Posted at
Sub CombineColumnsVertically()
    Dim ws As Worksheet
    Dim sourceRange As Range, targetRange As Range
    Dim col As Integer, targetRow As Long
    
    Set ws = ThisWorkbook.Sheets("Sheet2") ' シート名を適宜変更
    Set sourceRange = ws.Range("A1:C9") ' 取得したいデータの範囲を設定
    
    Set targetRange = ws.Range("D1") ' 結果を縦に並べる開始セルを指定
    
    targetRow = 0
    
    For col = 1 To sourceRange.Columns.Count
        targetRange.Offset(targetRow, 0).Resize(sourceRange.Rows.Count, 1).Value = sourceRange.Columns(col).Value
        targetRow = targetRow + sourceRange.Rows.Count
    Next col
End Sub
0
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
0
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?