Récuper Nom selon couleur interieur de cellule
Bonjour,
j'essaie de créer une base de données en récupérant des informations selon la couleur intérieur de la cellule.
Ma macro ne ramène rien mais elle ne se met pas en erreur.
Dans la macro "col 7 to 18" correspond de janvier à décembre (en ligne3)
La base de ma macro est :
Si le fond de la cellule est de couleur.. je récupère les données.
Pouvez-vous me dire la raison de ce retour vierge?
Merci de votre aide
tseoy
[code][/Sub BdDhorsoins()
Dim f As Worksheet, i%, etage As String, metier As String, ligne%
Dim col As Long
raz1
Application.ScreenUpdating = False
' indicateur départ en AH
' secteur = ActiveSheet.Name
' étage face à IDE/AS ou à un blanc
' IDE/AS (en début de liste)
ligne = 1
For Each f In Worksheets
With f
If f.Name Like "Secteur *" Or f.Name Like "Suppléance" Then
'If .Name <> ActiveSheet.Name Then
etage = ""
metier = ""
For col = 7 To 18
For i = 1 To .Cells(Rows.Count, col).End(xlUp).Row
If .Cells(i, "A").Value = "IDE" Or .Cells(i, "A").Value = "AS" Then metier = .Cells(i, "A").Value
If .Cells(i, "B").Value <> "" And (.Cells(i, "A").Value = "" Or .Cells(i, "A").Value = "IDE" Or .Cells(i, "A").Value = "AS") Then etage = .Cells(i, "B").Value
If .Cells(i, col).Interior.ColorIndex = RGB(255, 51, 255) Or .Cells(i, col).Interior.ColorIndex = RGB(102, 255, 255) _
Or .Cells(i, col).Interior.ColorIndex = RGB(172, 109, 255) Or .Cells(i, col).Interior.ColorIndex = RGB(255, 175, 177) _
Or .Cells(i, col).Interior.ColorIndex = RGB(255, 255, 255) Or .Cells(i, col).Interior.ColorIndex = RGB(197, 217, 241) Then
ligne = ligne + 1
Cells(ligne, 1).Value = metier
Cells(ligne, 4).Value = etage
'Cells(ligne, 4).Value = .Range("D" & i).Value
Cells(ligne, 2).Value = .Range("A" & i).Value & " " & .Range("B" & i).Value
Cells(ligne, 3).Value = .Range("c" & i).Value
Cells(ligne, 5).Value = .Cells(3, col).Value
Cells(ligne, 6).Value = .Name
End If
Next
Next
End If
End With
Next f
Trihorsoins
Application.ScreenUpdating = True
Sheets("feuil6").Select
End Sub
Sub Trihorsoins()
Range("Thorsoins[#All]").Select
With ActiveSheet.ListObjects("Thorsoins")
.Sort.SortFields.Clear
.Sort.SortFields.Add _
Key:=Range("Thorsoins[Grade]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
.Sort.SortFields.Add _
Key:=Range("Thorsoins[Secteur]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
.Sort.SortFields.Add _
Key:=Range("Thorsoins[Etage]"), SortOn:=xlSortOnValues, Order:=xlAscending _
, DataOption:=xlSortNormal
With .Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
End Sub
code]
pour compléter ma demande, voila comment mes cellules sont incrémentées
Private Sub ComboBox_couleurs_Change()
no_Couleur = ComboBox_couleurs.ListIndex
If no_Couleur = 0 Then
ComboBox_couleurs.BackColor = RGB(255, 51, 255)
ElseIf no_Couleur = 1 Then
ComboBox_couleurs.BackColor = RGB(102, 255, 255)
ElseIf no_Couleur = 2 Then
ComboBox_couleurs.BackColor = RGB(102, 255, 153)
ElseIf no_Couleur = 3 Then
ComboBox_couleurs.BackColor = RGB(172, 109, 255)
ElseIf no_Couleur = 4 Then
ComboBox_couleurs.BackColor = RGB(255, 175, 177)
ElseIf no_Couleur = 5 Then
ComboBox_couleurs.BackColor = RGB(255, 255, 255)
ElseIf no_Couleur = 6 Then
ComboBox_couleurs.BackColor = RGB(197, 217, 241)
ElseIf no_Couleur = 7 Then
ComboBox_couleurs.BackColor = RGB(34, 117, 238)
Else
ComboBox_couleurs.BackColor = &H80000005
End If
End Sub
Bonjour,
si les cellules sont coloriées avec une MFC, cela ne donnera rien ! est-ce le cas ?
si tu utilise RGB, alors utilise Interior.Color et non Interior.ColorIndex
Encore merci à STEELSON
cordialement
Tseoy