
Sub prova()
Dim i As Long
Dim ur As Long
Dim risultato As String
ur = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To ur
risultato = risultato & " " & Range("a" & i).Value
Next i
ActiveCell.Value = risultato
End Sub
|
Sub prova()
Dim ur As Long
ur = Cells(Rows.Count, 1).End(xlUp).Row
activecell = join(application.transpose(range("A1:A" & ur)), " ")
End Sub
|
Sub Concatena_Luca()
Dim Stringa As String
Dim Indice as Long
Indice = 0
Stringa = ""
Do
Stringa = Stringa & Range("A1").Offset(Indice, 0).Text
Indice = Indice + 1
Loop Until Range("A1").Offset(Indice, 0).Text = ""
Range("B1").Formula = Stringa
End Sub |
Option Explicit
Function flatten(ByVal r As Range, Optional delimiter As String = "", _
Optional bycol As Boolean = False) As String
'appiattisce un range riga per riga e restituisce una stringa
'(solo celle non vuote) ' si può specificare un delimitatore tra i
'diversi valori e se si specifica "bycol:=True", l'appiattimento è
'effettuato colonna per colonna
Dim vect() As Variant, v As Variant, i As Integer, s As String
Dim col As Range
If bycol Then
If r.Rows.Count = 1 Then
flatten = flatten(r, delimiter, False)
Exit Function
End If
s = ""
For Each col In r.Columns
s = s & Join(Application.Transpose(col), delimiter)
Next
flatten = s
Else
ReDim vect(0 To r.Cells.Count - 1)
For Each v In r.Cells
vect(i) = v
i = i + 1
Next
flatten = Join(vect, delimiter)
End If
End Function |
