Colorier une plage de cellule selon la ligne sélectionner

Bonjour à tous,

Sa fait un moment que je bute sur la façon de créer le code pour arriver à mes fins.

Dans la feuille "demande" j'ai quelque bouton, dont accepter la demande. Quand on actionne ce bouton selon la ligne que l'on a sélectionné avant, je souhaite que cela me colorie les cellules (A:F (selon la ligne sélectionné) en vert.

Je vous mets le fichier en pièce jointe si vous voulez regarder. C'est mon fichier test ;)

Le code (module 8) actuellement en test qui ne fonctionne pas :

' TestAccept Macro
'
    Range(("A:F") & Rows.Select).Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent6
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Rows.Copy
    Selection.Copy
    Sheets("Interventions").Select
    Rows("11:11").Select
    Selection.Insert Shift:=x1Down
    Range("G11:K11").Select
    Application.CutCopyMode = False
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
End Sub

Merci de votre aide ;)

Salut Biimoxx,

si je comprends bien, la ligne sélectionnée en 'Demandes' doit être copiée sur la première ligne vide en 'Interventions' et être soulignée de vert ?


A+

Bonjour Curulis57

C'est ça mais elle doit être mise en surbrillance vert :)

Salut Biimoxx,

ton fichier avec mes petits changements.

Sub TestAccept()
'
' TestAccept Macro
'
Dim iRow%, iTRow%
'
Application.ScreenUpdating = False
iRow = Selection.Row
Range("A" & iRow & ":F" & iRow).Interior.Color = RGB(110, 175, 70)
'
With Worksheets("Interventions")
    iTRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
    .Range("A" & iTRow & ":F" & iTRow).Value = Range("A" & iRow & ":F" & iRow).Value
    .Range("A" & iTRow & ":F" & iTRow).Borders.LineStyle = xlContinuous
End With
Application.ScreenUpdating = True
'
End Sub

La liste de validation en 'Interventions'-Intervenant- est créée à la demande. Code dans le module VBA de 'Interventions'.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'
Cells.Validation.Delete
If Not Intersect(Target, Columns(8)) Is Nothing Then _
    If Target.Count = 1 And Range("A" & Target.Row).Value <> "" Then _
        Target.Validation.Add Type:=xlValidateList, Formula1:="=Listes!B2:B" & Worksheets("Listes").Range("B" & Rows.Count).End(xlUp).Row
'
End Sub
19biimoxx.zip (246.37 Ko)


A+

Salut Curilis57,

Je te remercie énormément, j'aurais jamais pensé faire cela comme ça.

Cela me débloque dans mon processus. Merci encore ;)

Bon courage :)

Rechercher des sujets similaires à "colorier plage ligne selectionner"