nr = InputBox("Inserire il numero del treno:")
If nr = "" Or IsNumeric(nr) = False Then
Exit Sub
End If
x = 2
k = Cells(5, Columns.Count).End(xlToLeft).Column
If k > 1 Then
Range(Cells(2, 2), Cells(5, k)).ClearContents
With Range(Cells(2, 2), Cells(5, k))
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
End With
End If
Range("b1") = nr
For i = 2 To Sheets.Count
Set fin = Sheets(i).Columns(1).Find(what:=nr, lookat:=xlWhole)
If Not fin Is Nothing Then
firstAddress = fin.Address
Cells(2, x) = Sheets(i).Name
With Cells(2, x)
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
End With
Do
Cells(3, x) = fin.Offset(0, 7)
Cells(4, x) = fin.Offset(0, 8)
Cells(5, x) = fin.Offset(0, 9)
x = x + 1
Set fin = Sheets(i).Columns(1).FindNext(fin)
Loop While Not fin Is Nothing And fin.Address <> firstAddress
End If
Next
k = Cells(5, Columns.Count).End(xlToLeft).Column
With Range(Cells(3, 2), Cells(5, k))
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
End With |