
With Sheets("Foglio1").Activate
For Each cella In rng
cella = Trim(cella)
Next
Set elenco = rng
Set col = New Collection
On Error Resume Next
For Each nome In elenco
col.Add nome.Value, CStr(nome.Value)
Next
'per ogni valore della collection creo la lista
For Each valore In col
som = som + valore.Offset(0, 1)
With Sheets("Foglio1")
valore.Offset(0, 2) = som
End With
lista = lista & valore & ","
Next
lista = Replace(lista & "@", ",@", "")
End With |
Option Explicit
Sub check()
Dim cella As Range, valore_foglio1 As Integer, sum_valori_foglio2 As Integer, evaluate_string As String
For Each cella In Foglio1.[A1:A10]
If cella = "" Then Exit For
valore_foglio1 = cella.Offset(, 1)
evaluate_string = "SUMIF(foglio2!A1:A10, " & Chr(34) & cella & Chr(34) & ", foglio2!B1:B10)"
sum_valori_foglio2 = Evaluate(evaluate_string)
If valore_foglio1 = sum_valori_foglio2 Then cella.Offset(, 2) = "coincide!"
Next
End Sub |
Sub Diff()
Dim ur As Integer, ur2 As Integer
Dim rng As Range, dest As Range, rng2 As Range, valore As Range
Dim stringhe() As Variant, i As Integer
Dim v As Variant, col As Collection
Dim som As Double
Application.ScreenUpdating = False
With ActiveSheet
ur = Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range("e2:e" & ur)
ReDim stringhe(ur)
For Each dest In rng
stringhe(i) = Trim(dest.Offset(0, -3)) & Trim(dest) & Trim(dest.Offset(0, 7))
dest.Offset(0, 21) = stringhe(i)
i = i + 1
Next
If .AutoFilterMode = True Then
.AutoFilter.Range.AutoFilter
End If
Set col = New Collection
On Error Resume Next
For Each dest In Range("z2:z" & ur)
col.Add dest.Value, CStr(dest.Value)
Next
For Each v In col
Columns("Z").AutoFilter Field:=1, Criteria1:=v
For Each dest In rng.SpecialCells(xlCellTypeVisible)
If dest.Offset(0, 15).Interior.ColorIndex = 6 Then
som = som + dest.Offset(0, 12)
End If
Next
For Each dest In rng.SpecialCells(xlCellTypeVisible)
If dest.Offset(0, 15).Interior.ColorIndex = 6 Then
dest.Offset(0, 14).NumberFormat = "0.00"
dest.Offset(0, 14) = som
End If
Next
som = 0
.ShowAllData
Next
.AutoFilter.Range.AutoFilter
Columns("Z").ClearContents
End With |
