IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

[Evolution macro : outil de construction de devis restauration]


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2022
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Septembre 2022
    Messages : 1
    Par défaut [Evolution macro : outil de construction de devis restauration]
    Bonjour à toutes et à tous,

    Version : Microsoft® Excel® pour Microsoft 365 MSO (Version 2208 Build 16.0.15601.20072) 64 bits

    Je sèche sur les évolutions à apporter à une macro qui permet d’automatiser l’intégration de listes déroulantes dans plusieurs onglets selon certains critères.
    La commande actuelle ne répond pas pleinement aux attentes des utilisateurs et je souhaite intégrer une commande qui pour chaque cellule d’une sélection en colonne B va intégrer pour chaque cellule contigüe en colonne C une référence de liste déroulante spécifique selon les critères Case choix : Classique et B… <> 0 => C… = « liste1 » et ainsi de suite que les 3 critères de Case choix.
    Ci-dessous, un extrait du code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    Worksheets("Accueil").Select
        Dim Choix As String
        Choix = Range("G5")
        Select Case Choix
            Case "Classique"
                Range("C9:C47").Select
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_A"
                        Range("C9:C47") = "OUI"
                    End With
                Range("h9:h47").Select
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_D"
                         Range("h9:h47") = "100%"
                        End With
                    Range("k9:k47").Select
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_F"
                        Range("k9:k47") = "30%"
                    End With
            Case "_A_Personnaliser"
                Range("C9:C47").Select
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_B"
                        Range("C9:C47") = "NON"
                    End With
                Range("h9:h47").Select
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_E"
                        Range("h9:h47") = "100%"
                    End With
                Range("k9:k47").Select
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_G"
                        Range("k9:k47") = "30%"
                    End With
            Case Else
                Range("C9:C47").Select
                    Selection.ClearContents
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_C"
                    End With
                 Range("h9:h47").Select
                    Selection.ClearContents
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_H"
                    End With
                Range("k9:k47").Select
                    Selection.ClearContents
                    With Selection.validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                        xlBetween, Formula1:="=_H"
                    End With
               End Select
    En espérant que ma demande est assez explicite et suis preneur de toutes vos solutions.
    Bonne soirée

  2. #2
    Expert confirmé
    Homme Profil pro
    retraité
    Inscrit en
    Juin 2012
    Messages
    3 432
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : retraité
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Juin 2012
    Messages : 3 432
    Par défaut
    Bonjour,

    Pas assez clair pour moi. Voir si qq chose de ce genre ne correspond pas à votre demande:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    '...
        Select Case Choix
            Case "Classique"
                With Range("C9:C47").Validation
                    .Delete
                    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=_A"
                End With
                Range("C9:C47") = "OUI"
                With Range("H9:H47").Validation
                    .Delete
                    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=_D"
                End With
                Range("H9:H47") = "100%"
                With Range("K9:K47").Validation
                    .Delete
                    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=_F"
                End With
                Range("K9:K47") = "30%"
     '...
    Si j'ai bien interprété _A, _D, _F sont des tableaux structurés d'une colonne. Dans ce cas, pas d'opérateur xlBetween.

    Cordialement.

Discussions similaires

  1. Réponses: 0
    Dernier message: 15/09/2020, 15h34
  2. Réponses: 0
    Dernier message: 28/01/2010, 11h54
  3. Outil de construction de rapport
    Par methodman225 dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 0
    Dernier message: 24/03/2009, 10h05
  4. [MySQL] outil de construction de class php à partir de MYSQL
    Par Ontolingua dans le forum PHP & Base de données
    Réponses: 0
    Dernier message: 16/03/2009, 13h24
  5. [Java] Outil de construction de requête et affichage du résultat
    Par Toudy dans le forum Autres outils décisionnels
    Réponses: 1
    Dernier message: 07/05/2007, 10h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo