Bonjour tout le monde, je voudrais incrémenter 2 macros pour le meme onglet mais je n'y arrive pas.
Concretement, la 1ere me permet de cocher une case et la 2nde, je voudrais mettre en surbrillance la ligne active de ma feuille excel sans perdre la mise en forme existante.
merci de votre aide ! :)
voici ma macro initiale de l'onglet :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'restriction de la plage
If Target.Column > 6 Or Target.Row > 2500 Then Exit Sub 'plage A1:J20
If Target.Count = 1 Or Target.MergeCells Then
If Target.Font.Name = "Wingdings" Then
With Target 'cellule "liée"
.Value = Abs(.Range("A1").Value - 1)
.NumberFormat = """þ"";General;""o"";@"
Application.EnableEvents = False
.Range("A1").Offset(, 1).Select
Application.EnableEvents = True
End With
End If
End If
End Sub
voici celle que je voudrais incrémenter :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set champ = [A2:AT5000]
col1 = champ.Column
col2 = champ.Column + champ.Columns.Count - 1
For Each n In ActiveWorkbook.Names
If n.Name = "mémoNcol" Then trouvé = True
Next n
If trouvé Then
'---- restitution des couleurs
ncol = [mémoNCol]
For i = 1 To ncol
x = "mémoAdresse" & i
a = Evaluate([x])
x = "mémoCouleur" & i
b = Evaluate([x])
Range(a).Interior.ColorIndex = b
Next i
End If
'--- mémorisation des couleurs --------------------------
If Not Intersect(champ, Target) Is Nothing And Target.Count = 1 Then
ncol = col2 - col1 + 1
ActiveWorkbook.Names.Add Name:="mémoNcol", RefersToR1C1:= _
"=" & Chr(34) & ncol & Chr(34)
For i = 1 To ncol
ActiveWorkbook.Names.Add Name:="mémoAdresse" & i, RefersToR1C1:= _
"=" & Chr(34) & Cells(Target.Row, i + col1 - 1).Address & Chr(34)
ActiveWorkbook.Names.Add Name:="mémoCouleur" & i, RefersToR1C1:= _
"=" & Cells(Target.Row, i + col1 - 1).Interior.ColorIndex
Cells(Target.Row, i + col1 - 1).Interior.ColorIndex = 6
Next i
End If
End Sub