ieri mi sono imbattuto in un problema che ho risolto parzialmente. Parzialmente perche purtroppo ( avendo preso da poco in mano VBA per Excel) ho dovuto creare 6 macro.
Vi chiederei cortesemente se, secondo voi, è possibile cerare un unico codice che faccia tutto quanto.
sostanzialmente ho due codici diversi solo che uno si riepte 5 volte sempre piu esteso.
Vi copio il primo codice e poi due similari
- Codice: Seleziona tutto
Sub inserisciriga()
Dim fine As Long
fine = 10000
For x = 2 To fine
If Cells(x + 1, 1) <> Cells(x, 1) Then
Cells(x + 1, 1).Select
Selection.EntireRow.Insert
fine = fine + 1
x = x + 1
End If
Next x
End Sub
POI:
- Codice: Seleziona tutto
Sub Macro1()
For i = 1 To 7400
If Cells(i, 1) = Cells(i + 1, 1) Then
Cells(i + 1, 2).Select
Selection.Cut
Cells(i, 3).Select
ActiveSheet.Paste
Cells(i + 1, 1).Select
Selection.EntireRow.Delete
End If
Next i
End Sub
per arrivare all ultima macro che è
- Codice: Seleziona tutto
Sub Macro5()
For i = 1 To 6650
If Cells(i, 1) = Cells(i + 1, 1) Then
Cells(i + 1, 2).Select
Selection.Cut
Cells(i, 18).Select
ActiveSheet.Paste
Cells(i + 1, 3).Select
Selection.Cut
Cells(i, 19).Select
ActiveSheet.Paste
Cells(i + 1, 4).Select
Selection.Cut
Cells(i, 20).Select
ActiveSheet.Paste
Cells(i + 1, 5).Select
Selection.Cut
Cells(i, 21).Select
ActiveSheet.Paste
Cells(i + 1, 6).Select
Selection.Cut
Cells(i, 22).Select
ActiveSheet.Paste
Cells(i + 1, 7).Select
Selection.Cut
Cells(i, 23).Select
ActiveSheet.Paste
Cells(i + 1, 8).Select
Selection.Cut
Cells(i, 24).Select
ActiveSheet.Paste
Cells(i + 1, 9).Select
Selection.Cut
Cells(i, 25).Select
ActiveSheet.Paste
Cells(i + 1, 10).Select
Selection.Cut
Cells(i, 26).Select
ActiveSheet.Paste
Cells(i + 1, 11).Select
Selection.Cut
Cells(i, 27).Select
ActiveSheet.Paste
Cells(i + 1, 12).Select
Selection.Cut
Cells(i, 28).Select
ActiveSheet.Paste
Cells(i + 1, 13).Select
Selection.Cut
Cells(i, 29).Select
ActiveSheet.Paste
Cells(i + 1, 1).Select
Selection.EntireRow.Delete
End If
Next i
End Sub
vi ringrazio in anticipo per l'interessamento
EDIT Flash ore 04:50 - Inserito codice VBa nel contesto CODE