
Public Function QuId(fg As String, CL As Range) As Integer
Application.Volatile (True)
Dim suite1 As String, suite2 As String, Des As Range
Dim r As Long, s As Long, Sh As Worksheet, risp As Range, T As Long, i As Long
Dim a As String, b As String, c, d, e, f, a1 As String, b1 As String, c1, d1, e1, f1
r = CL.Row
a = Cells(r, 1).Value
b = Cells(r, 2).Value
c = Cells(r, 3).Value
d = Cells(r, 4).Value
e = Cells(r, 5).Value
f = Cells(r, 6).Value
suite1 = a & b & c & d & e & f
Set Sh = Sheets(fg)
i = 0
With Sh
Set Des = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row)
Set risp = Des.Find(a, LookIn:=xlValues)
If Not risp Is Nothing Then
s = risp.Row
For T = s To .Cells(Rows.Count, "A").End(xlUp).Row
a1 = .Cells(T, 1).Value
b1 = .Cells(T, 2).Value
c1 = .Cells(T, 3).Value
d1 = .Cells(T, 4).Value
e1 = .Cells(T, 5).Value
f1 = .Cells(T, 6).Value
suite2 = a1 & b1 & c1 & d1 & e1 & f1
If suite1 = suite2 Then i = i + 1
Next T
End If
End With
QuId = i
Set Sh = Nothing
Set risp = Nothing
Set Des = Nothing
End Function
'_______________________________________________________________________
Sub CopiaSeUnico()
Dim UrA As Long, UrB As Long, i As Long
Dim fg As String, qf As String
Dim fog As Worksheet, qfog As Worksheet
fg = Range("foglio").Value
Set fog = Sheets(fg)
qfog = ActiveSheets.Name
Set qf = Sheets(qfog)
UrA = qfog.Cells(Rows.Count, 1).End(xlUp).Row
For i = 4 To UrA
If QuId(fg, Cells(i, 1)) < 1 Then
UrB = fog.Cells(Rows.Count, 1).End(xlUp).Row
qfog.Range(Cells(i, 1), Cells(i, 6)).Copy
fog.Range(Cells(UrB, 1)).PasteSpecial (xlPasteValues)
End If
Next i
End Sub |
qfog = ActiveSheets.Name
qfog = ActiveSheet.Name
Set qf = Sheets(qfog)
qfog = ActiveSheet.Name ''SENZA ESSE Set qf = Sheets(qfog) |
Sub CopiaSeUnico()
Dim UrA As Long, UrB As Long, i As Long
Dim fg As String, qf As String
Dim fog As Worksheet, qfog As Worksheet
fg = Range("foglio").Value
Set fog = Sheets(fg)
qf = ActiveSheet.Name
Set qfog = Sheets(qf)
UrA = qfog.Cells(Rows.Count, 1).End(xlUp).Row
For i = 4 To UrA
If QuId(fg, Cells(i, 1)) < 1 Then
UrB = fog.Cells(Rows.Count, 1).End(xlUp).Row
qfog.Range(Cells(i, 1), Cells(i, 6)).Copy
fog.Range(Cells(UrB, 1)).PasteSpecial (xlPasteValues) ' SI BLOCCA QUI
End If
Next i
End Sub |
fog.Range(Cells(UrB+1, 1)).PasteSpecial (xlPasteValues) |
fog.Cells(UrB + 1, 1).PasteSpecial xlPasteValues |
Public Function QuId(fg As String, CL As Range) As Integer
Dim suite1 As String, suite2 As String, Des As Range
Dim r As Long, s As Long, Sh As Worksheet, risp As Range, T As Long, i As Long
Dim a As String, b As String, c, d, e, f, a1 As String, b1 As String, c1, d1, e1, f1
r = CL.Row
suite1 = Join(flatten(Range(Cells(r, 1), Cells(r, 6))), "")
Set Sh = Sheets(fg)
i = 0
With Sh
Set Des = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row)
Set risp = Des.Find(a, LookIn:=xlValues)
If Not risp Is Nothing Then
s = risp.Row
For T = s To .Cells(Rows.Count, "A").End(xlUp).Row
suite2 = Join(flatten(Range(Cells(T, 1), Cells(T, 6))), "")
If suite1 = suite2 Then i = i + 1
Next T
End If
End With
QuId = i
Set Sh = Nothing
Set risp = Nothing
Set Des = Nothing
End Function
Function flatten(r As Range) As Variant
Dim i As Integer, vect() As String, v As Variant
ReDim vect(1 To r.Count)
For Each v In r
i = i + 1
vect(i) = v
Next
flatten = vect
End Function
|
If suite1 = suite2 Then i = i + 1
Sub CopiaSeUnico()
Dim UrA As Long, UrB As Long, i As Long, Q As Integer
Dim fg As String, qf As String
Dim fog As Worksheet, qfog As Worksheet
Application.ScreenUpdating = False
fg = Range("foglio").Value
Set fog = Sheets(fg)
qf = ActiveSheet.Name
Set qfog = Sheets(qf)
UrA = qfog.Cells(Rows.Count, 1).End(xlUp).Row
For i = 4 To UrA
Q = QuId(fg, Cells(i, 1))
If Q < 1 Then
UrB = fog.Cells(Rows.Count, 1).End(xlUp).Row
MsgBox (qf & " - " & UrA & " - " & fg & " - " & UrB & " - " & Q & " - " & i) 'per controllare
qfog.Range(Cells(i, 1), Cells(i, 6)).Copy
fog.Cells(UrB + 1, 1).PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
End If
Next i
Application.ScreenUpdating = True
End Sub
Public Function QuId(fg As String, CL As Range) As Integer
Dim suite1 As String, suite2 As String, Des As Range
Dim r As Long, s As Long, Sh As Worksheet, risp As Range, T As Long, i As Long
Dim a As String, b As String, c, d, e, f, a1 As String, b1 As String, c1, d1, e1, f1
r = CL.Row
a = Cells(r, 1).Value
suite1 = Join(flatten(Range(Cells(r, 1), Cells(r, 6))), "")
Cells(r, 11) = suite1
Set Sh = Sheets(fg)
i = 0
With Sh
Set Des = .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row)
Set risp = Des.Find(a) ', LookIn:=xlValues)
If Not risp Is Nothing Then
s = risp.Row
For T = s To .Cells(Rows.Count, "A").End(xlUp).Row
suite2 = Join(flatten(Range(Cells(T, 1), Cells(T, 6))), "")
If suite1 = suite2 Then i = i + 1
Next T
End If
End With
QuId = i
Set Sh = Nothing
Set risp = Nothing
Set Des = Nothing
End Function
Function flatten(r As Range) As Variant
Dim i As Integer, vect() As String, v As Variant
ReDim vect(1 To r.Count)
For Each v In r
i = i + 1
vect(i) = v
Next
flatten = vect
End Function
|
