Morning again Pedro,
Here is some code to handle the id.s It consists of two parts. a module that populates the ID table from the data on the worksheets, and some event code to trigger it.
First, in the VBE IDE, add a new module, and paste this code in
Option Explicit
Public Const kResume As String = "Resumen"
Public Sub SetupIds()
Dim oWsResume As Worksheet
Dim Sh As Worksheet
Dim iLastRow As Long
Dim iNextRow As Long
Dim i As Long
Dim iID As Long
Dim sBaseFormula As String
Dim sFormula As String
Set oWsResume = Worksheets(kResume)
iNextRow = 1
oWsResume.Activate
'extract all unique ids from each worksheet
For Each Sh In ThisWorkbook.Worksheets
If Sh.Name <> oWsResume.Name Then
Sh.Range("B2:B40").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("AA" & iNextRow), _
Unique:=True
iNextRow = oWsResume.Cells(Rows.Count, "AA").End(xlUp).Row + 1
End If
Next Sh'now filter the amalgamated ids for uniqueness
oWsResume.Range("AA1:AA" & iNextRow - 1).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("AB1"), _
Unique:=True
'clear the id table
With Range("B23:D2000")
.ClearContents
.Interior.ColorIndex = xlNone
.Borders(xlLeft).LineStyle = xlNone
.Borders(xlRight).LineStyle = xlNone
.Borders(xlTop).LineStyle = xlNone
.Borders(xlBottom).LineStyle = xlNone
End With
'setup the table with unique ids
iID = 22
For i = 1 To Cells(Rows.Count, "AB").End(xlUp).Row
If Cells(i, "AB") <> "ID" And Cells(i, "AB") <> "" Then
iID = iID + 1
Cells(iID, "B").Value = Cells(i, "AB").Value
End If
Next i
'add formulas
sBaseFormula = _
"=SUMPRODUCT(COUNTIF(INDIRECT(""'""&ROW(INDIRECT(""1:31""))&""'!$B$3:$B$40""),$B23"
Range("C23").Formula = sBaseFormula & "))"
Range("D23").Formula = "=SUMPRODUCT(SUMIF(INDIRECT(""'""&ROW(INDIRECT(""1:31""))&""'!$B$3:$B$40""),$B23" & _
",INDIRECT(""'""&ROW(INDIRECT(""1:31""))&""'!$E$3:$E$40"")))"
Range("C23:D23").AutoFill Destination:=Range("C23:D" & iID)
'format ID table
With Range("B23:D" & iID)
.Interior.ColorIndex = 36
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
'delete temporary lists
Columns("AA:AB").Delete
End Sub
and then add this code to the ThisWorkbook code module.
Option Explicit
Private Sub Workbook_Open()
SetupIds
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim oWsThis As Worksheet
On Error GoTo ws_exit:
Application.EnableEvents = False
If Sh.Name <> kResume Then
Set oWsThis = Sh
If Not Intersect(Target, Sh.Range("B3:B40")) Is Nothing Then
SetupIds
Sh.Activate
End If
End If
ws_exit:
Application.EnableEvents = True
End Sub
Save and test.