- Codice: Seleziona tutto
Sub Compila1()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Range("C7:EV158").ClearContents
For RR = 7 To 158
For CC = 3 To 152
Str1 = Range("A" & RR).Value & Range("A1").Value & Cells(4, CC).Value & Range("B1").Value
For RR2 = 4 To 14
Str2 = Worksheets("OP_O").Range("U" & RR2).Value
If UCase(Str1) = UCase(Str2) Then
Cells(RR, CC).Value = Worksheets("OP_O").Range("V" & RR2).Value
Else
End If
Next RR2
Next CC
Next RR
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Call Compila2
End Sub
Sub Compila2()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Range("C161:EV313").ClearContents
For RR = 161 To 313
For CC = 3 To 152
Str1 = Range("A" & RR).Value & Range("A1").Value & Cells(4, CC).Value & Range("B2").Value
For RR2 = 4 To 14
Str2 = Worksheets("OP_O").Range("W" & RR2).Value
If UCase(Str1) = UCase(Str2) Then
Cells(RR, CC).Value = Worksheets("OP_O").Range("X" & RR2).Value
Else
End If
Next RR2
Next CC
Next RR
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Nel vba del foglio "AA oP" inserirai questo codice
- Codice: Seleziona tutto
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address <> "$A$2" Then Exit Sub
Call Compila1
End Sub
In maniera tale che cliccando due volte su A2 "Aggiornamento" si attiveranno le macro
Inoltre bisogna modificare la formattazione delle celle e mettere fondo rosso se <> ""
ho preferito non mettere caratteri per dimunire il peso del file che come vedrai ora è solo il 10% del tuo (660 kb contro 7.000 kb)
La velocità di esecuzione dipende dalla velocità del Pc ma si aggira intorno ai 15 secondi (per ambedue le macro).
Ma penso si possa fare di meglio...
allego file esempio
Fai sapere
ciao