OVH Cloud OVH Cloud

Ajustement sur mon code

3 réponses
Avatar
Caroline L.
Bonsoir,

y a t-il encore quelqu'un ou quelqu'une qui ne dort pas ?
j'ai encore besoin d'aide pour un ajustement.

Je désire modifier le code au bas pour que si l'usager clique sur la plage
suivante, le fond des cellules soit ColorIndex = 16.
voici la plage :
Range ("A:A"), Range ("I:V"), Range ("B29:H99")


Voici le code :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim ws As Worksheet
Set ws = ActiveSheet

If ws.ProtectContents Then
ws.Unprotect "1234"

Dim Rg As Range

Application.ScreenUpdating = False
Set plage = Union(Range("C6"), Range("C8:F8"), Range("C10:E10"),
Range("C12:F12"), Range("C14:E14"), Range("C16"), Range("C18:G18"),
Range("c20:g20"), Range("c22:g22"), Range("c24"))
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With


Set Rg = Intersect(Union(Range("C6"), Range("C8:F8"), Range("C10:E10"),
Range("C12:F12"), Range("C14:E14"), Range("C16"), Range("C18:G18"),
Range("c20:g20"), Range("c22:g22"), Range("c24")), Target)

plage.Interior.ColorIndex = xlNone


If Not Rg Is Nothing Then
Rg.Interior.ColorIndex = 37


End If
Application.ScreenUpdating = True


ws.Protect "1234"

End If

End Sub
-----------------------

Merci d'avance
Caroline

3 réponses

Avatar
Caroline L.
Je rectifie ma question.

Je désire modifier le code au bas pour que si l'usager clique sur la plage
Je ne veux pas modifier mais AJOUTER. Il s'agit d'ajouter des lignes de

codes.

:-)

"Caroline L." a écrit dans le message de news:
#
Bonsoir,

y a t-il encore quelqu'un ou quelqu'une qui ne dort pas ?
j'ai encore besoin d'aide pour un ajustement.

Je désire modifier le code au bas pour que si l'usager clique sur la plage
suivante, le fond des cellules soit ColorIndex = 16.
voici la plage :
Range ("A:A"), Range ("I:V"), Range ("B29:H99")


Voici le code :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim ws As Worksheet
Set ws = ActiveSheet

If ws.ProtectContents Then
ws.Unprotect "1234"

Dim Rg As Range

Application.ScreenUpdating = False
Set plage = Union(Range("C6"), Range("C8:F8"), Range("C10:E10"),
Range("C12:F12"), Range("C14:E14"), Range("C16"), Range("C18:G18"),
Range("c20:g20"), Range("c22:g22"), Range("c24"))
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With


Set Rg = Intersect(Union(Range("C6"), Range("C8:F8"), Range("C10:E10"),
Range("C12:F12"), Range("C14:E14"), Range("C16"), Range("C18:G18"),
Range("c20:g20"), Range("c22:g22"), Range("c24")), Target)

plage.Interior.ColorIndex = xlNone


If Not Rg Is Nothing Then
Rg.Interior.ColorIndex = 37


End If
Application.ScreenUpdating = True


ws.Protect "1234"

End If

End Sub
-----------------------

Merci d'avance
Caroline







Avatar
Papyty
Salut Caroline
Si tu dois colorer toute la plage essai

Set pl = Union(Range("a:a"), Range("i:v"), Range("$b$29:$h$99"))
If Not Intersect(Target, pl) Is Nothing Then
pl.Interior.ColorIndex = 16
End If

Si tu dois colorer la cellule active

Set pl = Union(Range("a:a"), Range("i:v"), Range("$b$29:$h$99"))
If Not Intersect(Target, pl) Is Nothing Then
Target.Interior.ColorIndex = 16
End If


@+
Thierry

Je rectifie ma question.


Je désire modifier le code au bas pour que si l'usager clique sur la plage


Je ne veux pas modifier mais AJOUTER. Il s'agit d'ajouter des lignes de
codes.

:-)

"Caroline L." a écrit dans le message de news:
#

Bonsoir,

y a t-il encore quelqu'un ou quelqu'une qui ne dort pas ?
j'ai encore besoin d'aide pour un ajustement.

Je désire modifier le code au bas pour que si l'usager clique sur la plage
suivante, le fond des cellules soit ColorIndex = 16.
voici la plage :
Range ("A:A"), Range ("I:V"), Range ("B29:H99")


Voici le code :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim ws As Worksheet
Set ws = ActiveSheet

If ws.ProtectContents Then
ws.Unprotect "1234"

Dim Rg As Range

Application.ScreenUpdating = False
Set plage = Union(Range("C6"), Range("C8:F8"), Range("C10:E10"),
Range("C12:F12"), Range("C14:E14"), Range("C16"), Range("C18:G18"),
Range("c20:g20"), Range("c22:g22"), Range("c24"))
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With


Set Rg = Intersect(Union(Range("C6"), Range("C8:F8"), Range("C10:E10"),
Range("C12:F12"), Range("C14:E14"), Range("C16"), Range("C18:G18"),
Range("c20:g20"), Range("c22:g22"), Range("c24")), Target)

plage.Interior.ColorIndex = xlNone


If Not Rg Is Nothing Then
Rg.Interior.ColorIndex = 37


End If
Application.ScreenUpdating = True


ws.Protect "1234"

End If

End Sub
-----------------------

Merci d'avance
Caroline












Avatar
Caroline L.
Bonjour Thierry,

merci à toi !
je vais faire d'autres tests.

Caroline

"Papyty" a écrit dans le message de news:
#
Salut Caroline
Si tu dois colorer toute la plage essai

Set pl = Union(Range("a:a"), Range("i:v"), Range("$b$29:$h$99"))
If Not Intersect(Target, pl) Is Nothing Then
pl.Interior.ColorIndex = 16
End If

Si tu dois colorer la cellule active

Set pl = Union(Range("a:a"), Range("i:v"), Range("$b$29:$h$99"))
If Not Intersect(Target, pl) Is Nothing Then
Target.Interior.ColorIndex = 16
End If


@+
Thierry

Je rectifie ma question.


Je désire modifier le code au bas pour que si l'usager clique sur la
plage




Je ne veux pas modifier mais AJOUTER. Il s'agit d'ajouter des lignes de
codes.

:-)

"Caroline L." a écrit dans le message de news:
#

Bonsoir,

y a t-il encore quelqu'un ou quelqu'une qui ne dort pas ?
j'ai encore besoin d'aide pour un ajustement.

Je désire modifier le code au bas pour que si l'usager clique sur la
plage



suivante, le fond des cellules soit ColorIndex = 16.
voici la plage :
Range ("A:A"), Range ("I:V"), Range ("B29:H99")


Voici le code :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim ws As Worksheet
Set ws = ActiveSheet

If ws.ProtectContents Then
ws.Unprotect "1234"

Dim Rg As Range

Application.ScreenUpdating = False
Set plage = Union(Range("C6"), Range("C8:F8"), Range("C10:E10"),
Range("C12:F12"), Range("C14:E14"), Range("C16"), Range("C18:G18"),
Range("c20:g20"), Range("c22:g22"), Range("c24"))
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With


Set Rg = Intersect(Union(Range("C6"), Range("C8:F8"), Range("C10:E10"),
Range("C12:F12"), Range("C14:E14"), Range("C16"), Range("C18:G18"),
Range("c20:g20"), Range("c22:g22"), Range("c24")), Target)

plage.Interior.ColorIndex = xlNone


If Not Rg Is Nothing Then
Rg.Interior.ColorIndex = 37


End If
Application.ScreenUpdating = True


ws.Protect "1234"

End If

End Sub
-----------------------

Merci d'avance
Caroline