Skip to content

Instantly share code, notes, and snippets.

@s-hiiragi
Created October 8, 2022 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-hiiragi/6b1e705a0ebb74c4bcf4d051f0d2129e to your computer and use it in GitHub Desktop.
Save s-hiiragi/6b1e705a0ebb74c4bcf4d051f0d2129e to your computer and use it in GitHub Desktop.
(Excel VBA) 複数のセル範囲を結合して返すサンプル
' 複数のセル範囲を結合する
Function JoinRanges(ParamArray rs() As Variant)
Dim c As Long
Dim i As Long
Dim k As Long
Dim r As Variant
Dim z() As Variant
c = 0
For Each r In rs
c = c + r.Count
Next
ReDim z(c - 1, 0)
k = 0
For Each r In rs
For i = 1 To r.Count
z(k, 0) = r(i)
k = k + 1
Next
Next
JoinRanges = z
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment