Bonjour,
Je souhaite transformer ce code de façon à ce que l’onglet TEMP_VREF soit supprimé et que sa colonne D intègre l’onglet VREF en colonne D (colonne D de VREF décalée en E). Je bloque un peu…
Voici le fichier si ça peut aider.
Test.xlsm (2,7 Mo)
Sub Make_Temp_VRF()
Dim WSvref As Worksheet, WStmp As Worksheet
Dim RangeVREF As Range, RangeTMP As Range
Set WSvref = ThisWorkbook.Worksheets(« VREF »)
Set WStmp = ThisWorkbook.Worksheets(« TEMP_VREF »)
WStmp.Range(« A2:D2000 »).ClearContents
Set RangeVREF = WSvref.Range(« A2:D » & WSvref.Range(« A1000 »).End(xlUp).Row)
Set RangeTMP = WStmp.Range(« A2 »).Resize(RangeVREF.Rows.Count, RangeVREF.Columns.Count)
RangeTMP.Value = RangeVREF.Value
End Sub
Sub Speed_Comparator()
Dim WSvref As Worksheet, WStmp As Worksheet
Dim RangeVREF As Range, RangeTMP As Range
Dim CellVREF As Range, CellTMP As Range
Dim TheTimer As Single
Dim x As Integer, y As Integer
TheTimer = Timer
Set WSvref = ThisWorkbook.Worksheets(« VREF »)
Set WStmp = ThisWorkbook.Worksheets(« TEMP_VREF »)
WSvref.Range(« D:D »).Interior.ColorIndex = xlNone
Set RangeVREF = WSvref.Range(« A2:A » & WSvref.Range(« A1000 »).End(xlUp).Row)
Set RangeTMP = WStmp.Range(« A2:A » & WStmp.Range(« A1000 »).End(xlUp).Row)
For Each CellVREF In RangeVREF
For Each CellTMP In RangeTMP
If CellVREF.Text = CellTMP.Text Then
With CellVREF.Offset(0, 3)
If .Value < CellTMP.Offset(0, 3).Value Then
.Value = CellTMP.Offset(0, 3).Value
.Interior.ColorIndex = 33
y = y + 1
Exit For
Else
If .Value > CellVREF.Offset(0, 2) Then
.Interior.ColorIndex = 4
Exit For
Else
.Interior.ColorIndex = xlNone
Exit For
End If
End If
End With
End If
Next CellTMP
x = x + 1
Next CellVREF
MsgBox x & " Comparaisons ont ?t? faites en " & Timer - TheTimer & " Secondes" & vbCrLf _
& y & " plus grande(s) vitesse(s) historique(s) retrouv?e(s)", vbInformation
End Sub
Je vous remercie pour votre aide.