comparaison debut de cellules

Polo001

XLDnaute Nouveau
Bonjour le forum,

Voici mon enigme, j'ai trouvé ce code et comme je n'en suis pas le concepteur je ne le saisis pas bien.

J'aimerais comparer au lieu de la cellule entière les 4 premiers lettres cad left(cell,4)
j'ai tourné ca dans tous les sens et seul le code orignial s'execute.

Et mon rêve secret ! que ces 4 premières lettres soient de 2 couleurs differentes pour être selectionner. Mais deja les 4 premieres lettres m'aiderais enormement.





Code:
Sub MarqueLesDoublons()
Dim Plage As Range, i&, Cell As Range, Rng As Range

On Error Resume Next
Set Plage = Application.InputBox("Plage à examiner", Type:=8)
If IsEmpty(Plage) Then Exit Sub

Application.ScreenUpdating = False

For Each Cell In Plage
For i = 1 To Plage.Count
Set Rng = Cell.Offset(i)
If Rng <> "" And Rng = Cell Then
Cell.Interior.ColorIndex = 43
Rng.Interior.ColorIndex = 43
Exit For
End If
Next i
Next Cell
Application.ScreenUpdating = True
End Sub


Merci !!!


EDIT : Merci beaucoup SergiO

Je n'arrive pas à repondre à mon sujet mais j'ai trouvé pour les couleurs

If Rng <> "" And Left(Rng, 4) = Left(Cell, 4) And Cell.Font.ColorIndex = 3 And Rng.Font.ColorIndex = 5 Or Cell.Font.ColorIndex = 5 And Rng.Font.ColorIndex = 3 And Rng <> "" And Left(Rng, 4) = Left(Cell, 4) Then
Cell.Interior.ColorIndex = 43
Rng.Interior.ColorIndex = 43

Au cas ou cela interesse quelqu'un.


Merci encore
 
Dernière édition:

Discussions similaires

  • Résolu(e)
Microsoft 365 FORMULE Excel VBA
Réponses
17
Affichages
860

Statistiques des forums

Discussions
312 515
Messages
2 089 235
Membres
104 074
dernier inscrit
Romuald MORVAN