Bonjour,

J'essaie de comparer la position de 2 cellules dans Excel mais sans succes.
Pouvez-vous me dire ce qui cloche dans mon code ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Public Sub SupInfAddress()
 
Dim Cell1 As Variant, Cell2 As Variant
 
'CAS 1
Cell1 = Range("A999").Address
MsgBox Cell1 'affiche $A$999
Cell2 = Range("A1000").Address
MsgBox Cell2 'affiche $A$1000
 
 
If Cell2 > Cell1 Then    'Affiche Inf
    MsgBox "Sup"
ElseIf Cell1 > Cell2 Then 'pour verifier qu'il soit possible d'obtenir le message Inf sans utiliser Else...
    MsgBox "Inf"
End If
 
 
'CAS2
Cell1 = Range("A1999").Address
MsgBox Cell1 'affiche $A$1999
Cell2 = Range("A1000").Address
MsgBox Cell2 'affiche $A$1000
 
 
If Cell2 > Cell1 Then 'Affiche Inf
    MsgBox "Sup"
ElseIf Cell1 > Cell2 Then 'pour verifier qu'il soit possible d'obtenir le message Inf sans utiliser Else...
    MsgBox "Inf"
End If
 
End Sub
Merci