
Sub a()
r = 3
destcol = 7
Do While Cells(r, 1) <> ""
If Cells(r, 1) = Cells(r - 1, 1) Then
Cells(r - 1, destcol) = Cells(r, 6)
destcol = destcol + 1
Rows(r).Delete
Else
destcol = 7
r = r + 1
End If
Loop
End Sub |
Option Explicit
Sub calcola()
Dim sh1 As Worksheet: Set sh1 = Worksheets("FILE INIZIALE") ' da cambiare casomai
Dim sh2 As Worksheet: Set sh2 = Worksheets("COME VORREI CHE DIVENTASSE") ' da cambiare casomai
Dim X As Long, Y As Long, RR As Long, R As Long, uriga1 As Long
Dim Art1 As String, Col As Long, Area1 As Range, R2 As Object
Application.ScreenUpdating = False
uriga1 = sh2.Range("A" & Rows.Count).End(xlUp).Row
If uriga2 > 1 Then
sh2.Range("A2:AA" & uriga2).ClearContents
End If
uriga1 = sh1.Range("A" & Rows.Count).End(xlUp).Row
RR = 2
Set Area1 = sh2.Range("A2:A" & uriga1)
For X = 2 To uriga1
Art1 = sh1.Cells(X, 1)
Set R2 = Area1.Find(Art1, LookIn:=xlValues, LookAt:=xlWhole)
If R2 Is Nothing Then
sh1.Range(sh1.Cells(X, 1), sh1.Cells(X, 6)).Copy
sh2.Cells(RR, 1).PasteSpecial
RR = RR + 1
Else
R = R2.Row
Col = sh2.Cells(R, Columns.Count).End(xlToLeft).Column
sh2.Cells(R, Col + 1) = sh1.Cells(X, 6)
End If
Next X
MsgBox " Fatto"
Application.ScreenUpdating = True
Set Area1 = Nothing
Set sh1 = Nothing
Set sh2 = Nothing
End Sub |
Sub Allinea()
Dim Nrighe As Long, Ncol As Long
Dim i, o As Long
Dim Nome As Variant
Ncol = 2
Nrighe = Sheets("FILE INIZIALE").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("FILE INIZIALE").Select
Range("A2:A" & Nrighe).Select
Selection.Copy
Sheets("Con Macro").Select
Range("A2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.Range("$A$1:$A$" & Nrighe).RemoveDuplicates Columns:=1, Header:=xlYes
Range("A1").Select
For o = 2 To Sheets("Con Macro").Cells(Rows.Count, "A").End(xlUp).Row
Nome = Sheets("Con Macro").Cells(o, 1)
For i = 2 To Nrighe
If Sheets("FILE INIZIALE").Cells(i, 1) = Nome Then
If Ncol = 2 Then
Sheets("Con Macro").Cells(o, Ncol) = Sheets("FILE INIZIALE").Cells(i, 2)
Ncol = Ncol + 1
Sheets("Con Macro").Cells(o, Ncol) = Sheets("FILE INIZIALE").Cells(i, 3)
Ncol = Ncol + 1
Sheets("Con Macro").Cells(o, Ncol) = Sheets("FILE INIZIALE").Cells(i, 4)
Ncol = Ncol + 1
Sheets("Con Macro").Cells(o, Ncol) = Sheets("FILE INIZIALE").Cells(i, 5)
Ncol = Ncol + 1
Sheets("Con Macro").Cells(o, Ncol) = Sheets("FILE INIZIALE").Cells(i, 6)
Else
Ncol = Ncol + 1
Sheets("Con Macro").Cells(o, Ncol) = Sheets("FILE INIZIALE").Cells(i, 6)
End If
End If
Next i
Ncol = 2
Next o
End Sub
|
