Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Emiliano Li,
ti ringrazio molto per le tue risposte e avrei un'ultima domanda sul codice che mi hai fornito.
Prego!
È possibile estrarre i valori univoci senza riordinarli dal più piccolo al più grande?
Certo: ogni tuo desiderio è un ordine! :-)
Prova qualcosa del genere:
'=========>>
Option Explicit
'--------->>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet, srcSH As Worksheet, destSH As Worksheet
Dim srcRng As Range, destRng As Range
Dim arrFogli As Variant
Dim arrDatiFoglio() As Variant, arrIn() As Variant
Dim arrOut() As Variant
Dim Res As Variant
Dim i As Long, LRow As Long
Dim UB As Long, UB2 As Long
Const sFoglioDestinazione As String = "Foglio4" '<<=== Modifica
Const sCellaDestinazione As String = "A1" '<<=== Modifica
Const sFogli As String = "1,2,3,4,5,6,7,8,9,10,11,12"
arrFogli = Split(sFogli, ",")
Set WB = ThisWorkbook
With WB
Set destSH = WB.Sheets(sFoglioDestinazione)
For Each SH In .Worksheets
With SH
Res = Application.Match(.Name, arrFogli, 0)
If Not IsError(Res) Then
With SH
LRow = LastRow(SH, .Columns("A:A"))
Set srcRng = .Range("A1:A" & LRow)
End With
arrDatiFoglio = srcRng.Value
If IsArrayAllocated(arrIn) Then
UB = UBound(arrIn)
End If
UB2 = UBound(arrDatiFoglio)
ReDim Preserve arrIn(1 To UB + UB2)
For i = 1 To UB2
arrIn(UB + i) = arrDatiFoglio(i, 1)
Next i
End If
End With
Next SH
End With
Set destRng = destSH.Range(sCellaDestinazione)
arrOut = myArrayList(arrIn)
With destRng.Resize(UBound(arrOut))
.NumberFormat = "@"
.Value = Application.Transpose(arrOut)
End With
End Sub
'--------->>
Public Function myArrayList(V As Variant)
Dim i As Long
Dim oArrayList As Object
Set oArrayList = CreateObject("System.Collections.ArrayList")
With oArrayList
For i = 1 To UBound(V)
.Add V(i) ', 1)
Next i
myArrayList = .ToArray
End With
End Function
'<<=========
===
Regards,
Norman