Se ho capito bene, tu vuoi creare
un elenco (es in colonna F)
partendo da una matrice (i dati in colonne B-D).
Cio' detto, credo che la cosa piu' semplice sia un Userfunction.
Ad esempio:
- Codice: Seleziona tutto
Function ArrToList(ByRef L1 As Range, Optional ByRef L2 As Range) As Variant
Dim oArr(), I As Long, cInd As Long, maxR As Long
'
If L2 Is Nothing Then Set L2 = L1.Cells(1, 1).Offset(0, 1).Resize(L1.Count, 1)
ReDim oArr(1 To Parent.Caller.Rows.Count)
If L1.Count > L2.Count Then maxR = L1.Count Else maxR = L2.Count
For I = 1 To maxR
If I <= L1.Rows.Count And L1.Cells(I, 1) <> "" Then cInd = cInd + 1: oArr(cInd) = L1.Cells(I, 1)
If cInd >= UBound(oArr) Then
oArr(cInd) = ". . ."
Exit For
End If
If I <= L2.Rows.Count And L2.Cells(I, 1) <> "" Then cInd = cInd + 1: oArr(cInd) = L2.Cells(I, 1)
If cInd >= UBound(oArr) Then
oArr(cInd) = ". . ."
Exit For
End If
Next I
For I = cInd + 1 To UBound(oArr)
oArr(I) = ""
Next I
ArrToList = Application.WorksheetFunction.Transpose(oArr)
End Function
Metti il codice in un Modulo standard del vba, poi sul tuo foglio seleziona F2:F10 e poi scrivi (nella barra della formula)
- Codice: Seleziona tutto
=ArrToList(B2:B13;D2:D7)
Adatta i due intervalli alle lunghezze delle tue colonne dati (che possono essere di diversa lunghezza e contenere celle vuote)
La formula e' da confermare con Contr-Maiusc-Enter
Se l'intervallo della formula (F2:F10 nell'esempio) non e' sufficiente per scrivere tutti i risultati, l'ultima cella conterra' ". . ."
In questo caso:
-seleziona ulteriori celle, es F2:F30
-premi F2, poi Contr-Maiusc-Enter
Ciao