Skip to content

Instantly share code, notes, and snippets.

@s-hiiragi
Created October 7, 2022 18:38
Show Gist options
  • Save s-hiiragi/27144fbe1bd0c31c3b0c69937665f91a to your computer and use it in GitHub Desktop.
Save s-hiiragi/27144fbe1bd0c31c3b0c69937665f91a to your computer and use it in GitHub Desktop.
(Excel VBA) 2つのセル範囲を結合して返すサンプル
' 2つのセル範囲を結合する
Function JoinRange(x As Range, y As Range)
Dim xCnt As Long
Dim yCnt As Long
Dim i As Long
Dim z()
xCnt = x.Count
yCnt = y.Count
ReDim z(xCnt + yCnt - 1, 0)
For i = 1 To xCnt
z(i - 1, 0) = x(i)
Next
For i = 1 To yCnt
z(xCnt + i - 1, 0) = y(i)
Next
JoinRange = z
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment