
Option Explicit
Sub estrai()
Dim find_cell As Range, table As Range, ac As Range, find_first As String, i As Integer, j As Integer
Set table = [A1].CurrentRegion.Offset(1, 1).Resize([A1].CurrentRegion.Rows.Count - 1, [A1].CurrentRegion.Columns.Count - 1)
For Each ac In table.Rows(1).Cells
j = j + 1
i = 0
With table
Set find_cell = table.Cells(1).Find(ac)
If Not (find_cell Is Nothing) Then
find_first = find_cell.Address
i = i + 1
Do
Cells(11 + i, 1 + j) = Cells(find_cell.Row, 1) & Cells(1, find_cell.Column)
Set find_cell = .FindNext(find_cell)
i = i + 1
Loop While Not (find_cell Is Nothing) And (find_cell.Address <> find_first)
End If
End With
Next
End Sub |
Option Explicit
Sub estrai()
Dim find_cell As Range, table As Range, ac As Range, find_first As String, i As Integer, j As Integer
Const NUM_RIGHE_SOTTO = 5
Set table = [A1].CurrentRegion.Offset(1, 1).Resize([A1].CurrentRegion.Rows.Count - 1, [A1].CurrentRegion.Columns.Count - 1)
Cells(2 + table.Rows.Count + NUM_RIGHE_SOTTO, 1) = 1
Cells(3 + table.Rows.Count + NUM_RIGHE_SOTTO, 1) = 2
Range(Cells(2 + table.Rows.Count + NUM_RIGHE_SOTTO, 1), Cells(3 + table.Rows.Count + NUM_RIGHE_SOTTO, 1)).AutoFill Range(Cells(2 + table.Rows.Count + NUM_RIGHE_SOTTO, 1), Cells(1 + table.Rows.Count * 2 + NUM_RIGHE_SOTTO, 1))
j = 1
For Each ac In table.Rows(1).Cells
i = table.Rows.Count + 1 + NUM_RIGHE_SOTTO
With table
Set find_cell = table.Rows(1).Find(ac)
If Not (find_cell Is Nothing) Then
find_first = find_cell.Address
Cells(i, j + 1) = ac
Cells(i, j + 1).Font.Bold = True
i = i + 1
Do
Cells(i, j + 1) = Cells(find_cell.Row, 1) & Cells(1, find_cell.Column)
Set find_cell = .FindNext(find_cell)
i = i + 1
Loop While Not (find_cell Is Nothing) And (find_cell.Address <> find_first)
End If
End With
j = j + 1
Next
End Sub |
