XL 2010 anomalie VBA

eastwick

XLDnaute Impliqué
Bonjour à toutes et tous,
Dans le fichier joint, quand je tape CA ou RTT dans une des cellules correspondant à un jour de l'année, la coloration de ladite cellule s'effectue correctement mais à la fin, toute la feuille est sélectionnée. Ca ne pose pas de problème en soi mais je préfèrerai une validation classique avec un positionnement du "curseur" sous la cellule que je viens de remplir. Cela vient du code VBA.
Un grand merci.
 

Pièces jointes

  • Planning congés.xlsm
    369.5 KB · Affichages: 13

job75

XLDnaute Barbatruc
Bonjour eastwick,

Avec 547 posts à votre actif vous ne savez toujours pas qu'en VBA les Select sont à proscrire ?

De toute façon votre macro Worksheet_Calculate était monstrueuse, je l'ai revue :
Code:
Private Sub Worksheet_Calculate()
Dim c As Range
Application.ScreenUpdating = False
For Each c In Range("B5:BI14").Columns
    c.Interior.Color = c.Cells(0, 1)
Next
For Each c In Range("B20:BJ29").Columns
    c.Interior.Color = c.Cells(0, 1)
Next
For Each c In Range("B35:BJ44").Columns
    c.Interior.Color = c.Cells(0, 1)
Next
For Each c In Range("B50:BK59").Columns
    c.Interior.Color = c.Cells(0, 1)
Next
For Each c In Range("B65:BJ74").Columns
    c.Interior.Color = c.Cells(0, 1)
Next
For Each c In Range("B80:BJ89").Columns
    c.Interior.Color = c.Cells(0, 1)
Next
For Each c In Range("B95:AF104").Columns
    c.Interior.Color = c.Cells(0, 1)
Next

Cells.FormatConditions.Delete
UsedRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
    Formula1:="=""CA"""
UsedRange.FormatConditions(1).Interior.ColorIndex = 43
UsedRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
    Formula1:="=""RTT"""
UsedRange.FormatConditions(2).Interior.ColorIndex = 23

End Sub
A+
 

Pièces jointes

  • Planning congés(1).xlsm
    326.6 KB · Affichages: 10

Discussions similaires

Réponses
12
Affichages
483
Réponses
8
Affichages
430

Statistiques des forums

Discussions
311 720
Messages
2 081 924
Membres
101 841
dernier inscrit
ferid87