
Private Sub Worksheet_Activate()
Range("O2:O" & Sheets.Count - 2).ClearContents
For i = 2 To Sheets.Count - 1
If Sheets(i).Name <> "riepilogo" Then
Range("O" & i).Value = Sheets(i).Name
End If
Next i
End Sub
|
Private Sub Worksheet_Activate()
Range("O2:O" & Sheets.Count - 2).ClearContents
For i = 2 To Sheets.Count - 1
If Sheets(i).Name <> "riepilogo" Then
Sheets(i).Name = Replace(Sheets(i).Name, " ", "")
Range("O" & i).Value = Sheets(i).Name
End If
Next i
End Sub
|
| scossa's web site |
| Se tu hai una mela, ed io ho una mela, e ce le scambiamo, allora tu ed io abbiamo sempre una mela per uno. Ma se tu hai un'idea, ed io ho un'idea, e ce le scambiamo, allora abbiamo entrambi due idee. (George Bernard Shaw) |
Sub riepilogo()
Application.ScreenUpdating = False
r = Sheets("riepilogo ordinato").Range("b" & Rows.Count).End(xlUp).Row
For i = 2 To Sheets.Count - 1
k = Sheets(i).Range("b2").End(xlDown).Row
Sheets("riepilogo ordinato").Range("a" & r + 1 & ":z" & r + k - 1) = Sheets(i).Range("a2:Z" & k).Value
r = r + k - 1
Next
Range("a2:Z" & r).Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlNo
Application.ScreenUpdating = True
End Sub |
Option Explicit
Sub riepilogoaccorpa2()
Dim ws As Worksheet, r As Long, k As Long, i As Long, arr, ce
Application.ScreenUpdating = False
Sheets("riepilogo ordinato").Select
'Sheets("riepilogo ordinato").Cells.ClearContents
r = Sheets("riepilogo ordinato").Range("b" & Rows.Count).End(xlUp).Row
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "NUOVO" And ws.Name <> "riepilogo" And ws.Name <> "riepilogo ordinato" Then
With ws
k = ws.Range("b2").End(xlDown).Row
Sheets("riepilogo ordinato").Range("a" & r + 1 & ":y" & r + k - 1) = ws.Range("a2:y" & k).Value
r = r + k - 1
End With
End If
Next ws
Sheets("riepilogo ordinato").Range("a2:y" & r).Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlNo
For i = r To 2 Step -1
If Cells(i, 2) = Cells(i - 1, 2) And Cells(i, 3) = Cells(i - 1, 3) And Cells(i, 4) = Cells(i - 1, 4) And Cells(i, 5) = Cells(i - 1, 5) And Cells(i, 6) = Cells(i - 1, 6) And Cells(i, 7) = Cells(i - 1, 7) And Cells(i, 8) = Cells(i - 1, 8) And Cells(i, 9) = Cells(i - 1, 9) And Cells(i, 10) = Cells(i - 1, 10) Then
arr = Array(Cells(i, 11), Cells(i, 12), Cells(i, 13), Cells(i, 14), Cells(i, 15), Cells(i, 16), Cells(i, 17), Cells(i, 18), Cells(i, 19), Cells(i, 20), Cells(i, 21), Cells(i, 23), Cells(i, 24))
For Each ce In arr
If ce <> "" And ce <> " " Then
ce.Offset(-1, 0) = ce.Offset(-1, 0) + ce.Value
End If
Next
Rows(i).Delete
End If
Next
MsgBox "fatto"
Application.ScreenUpdating = True
End Sub |
Option Explicit
Sub riepilogoaccorpa2()
Dim ws As Worksheet, r As Long, k As Long, i As Long, arr, ce
Application.ScreenUpdating = False
Sheets("riepilogo ordinato").Select
'Sheets("riepilogo ordinato").Cells.ClearContents
r = Sheets("riepilogo ordinato").Range("b" & Rows.Count).End(xlUp).Row
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "NUOVO" And ws.Name <> "riepilogo" And ws.Name <> "riepilogo ordinato" Then
With ws
k = ws.Range("b2").End(xlDown).Row
Sheets("riepilogo ordinato").Range("a" & r + 1 & ":z" & r + k - 1) = ws.Range("a2:z" & k).Value
r = r + k - 1
End With
End If
Next ws
Sheets("riepilogo ordinato").Range("a2:z" & r).Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlNo
For i = r To 2 Step -1
If Cells(i, 2) = Cells(i - 1, 2) And Cells(i, 3) = Cells(i - 1, 3) And Cells(i, 4) = Cells(i - 1, 4) And Cells(i, 5) = Cells(i - 1, 5) And Cells(i, 6) = Cells(i - 1, 6) And Cells(i, 7) = Cells(i - 1, 7) And Cells(i, 8) = Cells(i - 1, 8) And Cells(i, 9) = Cells(i - 1, 9) And Cells(i, 10) = Cells(i - 1, 10) Then
arr = Array(Cells(i, 11), Cells(i, 12), Cells(i, 13), Cells(i, 14), Cells(i, 15), Cells(i, 16), Cells(i, 17), Cells(i, 18), Cells(i, 19), Cells(i, 20), Cells(i, 21), Cells(i, 23), Cells(i, 24))
For Each ce In arr
If ce <> "" And ce <> " " Then
ce.Offset(-1, 0) = ce.Offset(-1, 0) + ce.Value
End If
Next
Rows(i).Delete
End If
Next
MsgBox "fatto"
Application.ScreenUpdating = True
End Sub
|
Option Explicit
Sub riepilogoaccorpa2()
Dim sh1 As Worksheet: Set sh1 = Worksheets("riepilogo ordinato") ' da cambiare casomai
Dim ws As Worksheet, r As Long, k As Long, i As Long, Ur As Long, arr, ce
Application.ScreenUpdating = False
'ws1.Cells.ClearContents
r = sh1.Range("b" & Rows.Count).End(xlUp).Row
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "NUOVO" And ws.Name <> "riepilogo" And ws.Name <> "riepilogo ordinato" Then
With ws
k = ws.Range("b2").End(xlDown).Row
sh1.Range("a" & r + 1 & ":z" & r + k - 1) = ws.Range("a2:z" & k).Value
r = r + k - 1
End With
End If
Next ws
For i = r To 2 Step -1
If Cells(i, 2) = Cells(i - 1, 2) And Cells(i, 3) = Cells(i - 1, 3) And Cells(i, 4) = Cells(i - 1, 4) And Cells(i, 5) = Cells(i - 1, 5) And Cells(i, 6) = Cells(i - 1, 6) And Cells(i, 7) = Cells(i - 1, 7) And Cells(i, 8) = Cells(i - 1, 8) And Cells(i, 9) = Cells(i - 1, 9) And Cells(i, 10) = Cells(i - 1, 10) Then
arr = Array(Cells(i, 11), Cells(i, 12), Cells(i, 13), Cells(i, 14), Cells(i, 15), Cells(i, 16), Cells(i, 17), Cells(i, 18), Cells(i, 19), Cells(i, 20), Cells(i, 21), Cells(i, 23), Cells(i, 24))
For Each ce In arr
If ce <> "" And ce <> " " Then
ce.Offset(-1, 0) = ce.Offset(-1, 0).Value + ce.Value
End If
Next
Rows(i).Delete
End If
Next i
Ur = sh1.Range("A" & Rows.Count).End(xlUp).Row
sh1.Sort.SortFields.Clear
sh1.Sort.SortFields.Add Key:=Range("G2:G" & Ur), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
sh1.Sort.SortFields.Add Key:=Range("H2:H" & Ur), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
sh1.Sort.SortFields.Add Key:=Range("I2:I" & Ur), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With sh1.Sort
.SetRange Range("A1:AA" & Ur)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
MsgBox "fatto"
Application.ScreenUpdating = True
Set sh1 = Nothing
End Sub
|
Option Explicit
Sub riepilogoalex()
Dim ws As Worksheet, r As Long, k As Long, i As Long, arr, ce
Application.ScreenUpdating = False
Sheets("riepilogo ordinato").Select
'Sheets("riepilogo ordinato").Cells.ClearContents
r = Sheets("riepilogo ordinato").Range("b" & Rows.Count).End(xlUp).Row
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "NUOVO" And ws.Name <> "riepilogo" And ws.Name <> "riepilogo ordinato" Then
With ws
k = ws.Range("b2").End(xlDown).Row
Sheets("riepilogo ordinato").Range("a" & r + 1 & ":z" & r + k - 1) = ws.Range("a2:z" & k).Value
r = r + k - 1
End With
End If
Next
ActiveWorkbook.Worksheets("riepilogo ordinato").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("riepilogo ordinato").Sort.SortFields.Add Key:= _
Range("B2:B50000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("riepilogo ordinato").Sort.SortFields.Add Key:= _
Range("G2:G50000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("riepilogo ordinato").Sort.SortFields.Add Key:= _
Range("H2:H50000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("riepilogo ordinato").Sort.SortFields.Add Key:= _
Range("I2:I50000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("riepilogo ordinato").Sort
.SetRange Range("A1:Z50000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
MsgBox "fatto"
Application.ScreenUpdating = True
End Sub
|
