code vba pour afficher une combinaison en couleur

  • Initiateur de la discussion Initiateur de la discussion julien clerc
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

J

julien clerc

Guest
bonjour à tous j'aimerais modifier ma vba afin d'afficher une combinaison en rouge
ex: 1 2 3 4 = rouge
merci de m'aider
 
Re : code vba pour afficher une combinaison en couleur

Bonjour julien,

En gros, tu ne nous donnes rien et nous, on devrait tout de donner...

Si tu veux qu'on t'aide, il faut nous fournir ton code VBA et un fichier exemple. Sinon, tu restera avec ta question.

A+
 
Re : code vba pour afficher une combinaison en couleur

désolé Fredo 🙂

Sub combinaisons()
lin = 1
col = 1
For m = 1 To 20
For n = m + 1 To 20
For o = n + 1 To 20
For p = o + 1 To 20
For q = p + 1 To 20
Cells(lin, col) = m & " " & n & " " & " " & o & " " & p & " " & q
lin = lin + 1
If lin > 65536 Then
col = col + 1
lin = 1
End If
Next q
Next p
Next o
Next n
Next m
End Sub
 
Re : code vba pour afficher une combinaison en couleur

Re-bonjour,

Si j'ai bien tout compris, tu peux essayer le code suivant :
VB:
Sub combinaisons()
    lin = 1
    col = 1
    For m = 1 To 20
        For n = m + 1 To 20
            For o = n + 1 To 20
                For p = o + 1 To 20
                    For q = p + 1 To 20
                        Cells(lin, col) = m & " " & n & " " & o & " " & p & " " & q
                        If Cells(lin, col) = "1 2 3 4 5" Then
                            Cells(lin, col).Font.ColorIndex = 3
                        End If
                        lin = lin + 1
                        If lin < 65536 Then
                            col = col + 1
                            lin = 1
                        End If
                    Next q
                Next p
            Next o
        Next n
    Next m
End Sub

A+
 
Re : code vba pour afficher une combinaison en couleur

re fredo j'ai un petit problème, je ne trouve pas le code exacte pour modifier ma vba
car quant je lance ma vba j'ai le message suivent : mémoire insuffisante . voici ma combinaison
Sub combinaisons()
lin = 1
col = 1
For m = 1 To 49
For n = m + 1 To 49
For o = n + 1 To 49
For p = o + 1 To 49
For q = p + 1 To 49
Cells(lin, col) = m & " " & n & " " & " " & o & " " & p & " " & q
lin = lin + 1
If lin > 10 Then
col = col + 1
lin = 1
End If
Next q
Next p
Next o
Next n
Next m
End Sub

Merci de ton aide
 
Re : code vba pour afficher une combinaison en couleur

Re-onjour,

C'est normal, ton code dépasse les capacités d'EXCEL; si tu change de colonne toutes les 10 combinaisons, sachant qu'EXCEL 2010 a une capacité de 16384 colonnes, tu ne peux avoir que 163840 combinaisons. Or, tu en as largement plus. Je te conseille donc de changer de colonne toutes les 1000 combinaisons. Ton code devient donc :
VB:
Sub combinaisons()
    Application.ScreenUpdating = False
    Cells.ClearContents
    lin = 1
    col = 1
    For m = 1 To 49
        For n = m + 1 To 49
            For o = n + 1 To 49
                For p = o + 1 To 49
                    For q = p + 1 To 49
                        Cells(lin, col) = m & " " & n & " " & " " & o & " " & p & " " & q
                        lin = lin + 1
                        If lin > 1000 Then
                            col = col + 1
                            lin = 1
                        End If
                    Next q
                Next p
            Next o
        Next n
    Next m
    Application.ScreenUpdating = True
End Sub

A+
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD
Assurez vous de marquer un message comme solution pour une meilleure transparence.

Discussions similaires

  • Question Question
Réponses
2
Affichages
80
Réponses
1
Affichages
73
  • Question Question
Microsoft 365 Suivi charge/capa
Réponses
10
Affichages
339
Réponses
5
Affichages
196
Retour