“EXCEL VBA CONCATENATE Range” Réponses codées

Excel VBA combine des gammes

With Sheet1
Set rng1 = .Range("A1:A3")
Set rng2 = .Range("C1:C3")

'This combines the two separate ranges, so select A1, A2, A3, C1, C2, C3
set newRng = Union(rng1, rng2)

'This combines the two ranges in the same way as when using "A1:C3", 
'so including the cells from column B
set newRng = .Range(rng1, rng2)
VasteMonde

EXCEL VBA CONCATENATE Range

Public Function ConcatenateRange(pRange As Range, Optional pDelimiter As String = " ") As String
    ConcatenateRange = Join(WorksheetFunction.Transpose(pRange.Value), pDelimiter)
End Function

Sub TestMe()
    Dim r As Range
    Set r = ThisWorkbook.Worksheets(1).Range("A1:A10")
    MsgBox ConcatenateRange(r)
End Sub
VasteMonde

Réponses similaires à “EXCEL VBA CONCATENATE Range”

Questions similaires à “EXCEL VBA CONCATENATE Range”

Plus de réponses similaires à “EXCEL VBA CONCATENATE Range” dans VBA

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code