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 :

Form control lié à un TCD


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Supply planner
    Inscrit en
    Août 2018
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Supply planner

    Informations forums :
    Inscription : Août 2018
    Messages : 23
    Par défaut Form control lié à un TCD
    Bonjour à tous,

    J'ai mis au point une petite macro pour sortir un graphique croisé dynamique j'ai utiliser un filtre ("slicer") sur celui-ci mais ça reste pas très ergonomique à l'usage je voudrais pouvoir passer d'une donné traité à une autre simplement avec les flèches.
    Je souhaiterais y ajouter un Form control type list box ou spin button mais j'ai de la procédure pour lié celui-ci au tableau.
    En vous remerciant par avance,

    Cdlt,

    Benjamin

    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
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    Sub Mixtsizing()
    'Declare Variables
    Dim PSheet As Worksheet
    Dim DSheet As Worksheet
    Dim PCache As PivotCache
    Dim PTable As PivotTable
    Dim PRange As Range
    Dim LastRow As Long
    Dim LastCol As Long
    Dim p As PivotField
     
    'Insert a New Blank Worksheet
    On Error Resume Next
    Application.DisplayAlerts = False
    Worksheets("PivotChart").Delete
    Sheets.Add Before:=ActiveSheet
    ActiveSheet.Name = "PivotChart"
    Application.DisplayAlerts = True
    Set PSheet = Worksheets("PivotChart")
    Set DSheet = Worksheets("PO files")
     
    'Define Data Range
    LastRow = DSheet.Cells(Rows.Count, 1).End(xlUp).Row
    LastCol = DSheet.Cells(1, Columns.Count).End(xlToLeft).Column
    Set PRange = DSheet.Cells(1, 1).Resize(LastRow, LastCol)
     
    'Define Pivot Cache
    Set PCache = ActiveWorkbook.PivotCaches.Create _
    (SourceType:=xlDatabase, SourceData:=PRange). _
    CreatePivotTable(TableDestination:=PSheet.Cells(2, 2), _
    TableName:="Mixt sizing PO")
     
    'Insert Blank Pivot Table
    Set PTable = PCache.CreatePivotTable _
    (TableDestination:=PSheet.Cells(1, 1), TableName:="Mixt sizing PO")
     
    'Insert Row Fields & Column
     
    With ActiveSheet.PivotTables("Mixt sizing PO").PivotFields("Grid Value")
    .Orientation = xlRowField
    .Position = 1
    End With
    With ActiveSheet.PivotTables("Mixt sizing PO").PivotFields("Article")
    .Orientation = xlColumnField
    .Position = 1
    End With
     
     
    With ActiveSheet.PivotTables("Mixt sizing PO").PivotFields("Requested Delivery Date")
    .Orientation = xlPageField
    .Position = 1
    End With
    With ActiveSheet.PivotTables("Mixt sizing PO").PivotFields("lead time")
    .Orientation = xlPageField
    .Position = 1
    End With
    With ActiveSheet.PivotTables("Mixt sizing PO").PivotFields("Customer Name")
    .Orientation = xlPageField
    .Position = 1
    End With
     
    'Insert Data Field
    With ActiveSheet.PivotTables("Mixt sizing PO").PivotFields("Requested Quantity")
    .Orientation = xlDataField
    .Function = xlSum
    .NumberFormat = "#,##0"
    .Name = "Quantity"
    End With
     
    'Format Pivot Table
     
    ActiveSheet.PivotTables("Mixt sizing PO").RowAxisLayout xlTabularRow
    ActiveSheet.PivotTables("Mixt sizing PO").RepeatAllLabels xlRepeatLabels
    ActiveSheet.PivotTables("Mixt sizing PO").TableStyle2 = "PivotStyleDark9"
     
    For Each p In ActiveSheet.PivotTables(1).PivotFields 'delt subtotal
        If p.Orientation = 1 Then p.Subtotals = Array(False, False, False, False, _
            False, False, False, False, False, False, False, False)
    Next p
     
        Range("J18").Select
        ActiveSheet.Shapes.AddChart2(332, xlLineMarkers).Select
        ActiveChart.SetSourceData Source:=Range(ActiveSheet.PivotTables("Mixt sizing PO"))
        ActiveWorkbook.SlicerCaches.Add2(ActiveChart.PivotLayout.PivotTable, "Article") _
            .Slicers.Add ActiveSheet, , "Article 1", "Article", 211.5, 306.75, 144, 187.5
        ActiveSheet.Shapes.Range(Array("Article 1")).Select
        ActiveSheet.Shapes("Article 1").IncrementLeft 363
        ActiveSheet.Shapes("Article 1").IncrementTop -71.25
        With ActiveWorkbook.SlicerCaches("Slicer_Article1")
     
        End With
     
    End Sub

  2. #2
    Membre chevronné
    Femme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2012
    Messages
    214
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Septembre 2012
    Messages : 214
    Par défaut
    Tu peux nous déposer un fichier, c'est difficile de comprendre et de modifier sinon.

  3. #3
    Membre averti
    Homme Profil pro
    Supply planner
    Inscrit en
    Août 2018
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Supply planner

    Informations forums :
    Inscription : Août 2018
    Messages : 23
    Par défaut
    Bonjour Sogedic,

    Tout d'abord merci beaucoup pour ta réponse ! En PJ tu trouveras un draft de mon fichier excel. Dans l'idéal je voudrais utiliser les flèches (clavier) pour faire défiler les articles dans le slicer tool.

    En te remerciant par avance pour ton aide,

    Bien cdlt,

    B
    Fichiers attachés Fichiers attachés

  4. #4
    Membre averti
    Homme Profil pro
    Supply planner
    Inscrit en
    Août 2018
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Supply planner

    Informations forums :
    Inscription : Août 2018
    Messages : 23
    Par défaut
    Bonjour,

    Personne aurait une petite idée pour résoudre mon problème d'ergonomie ?

    En vous remerciant,

  5. #5
    Expert éminent

    Profil pro
    Conseil, Formation, Développement - Indépendant
    Inscrit en
    Février 2010
    Messages
    8 564
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Conseil, Formation, Développement - Indépendant

    Informations forums :
    Inscription : Février 2010
    Messages : 8 564
    Par défaut
    Bonjour

    On peut se déplacer dans un segment ainsi :

    sélection du 1er élément ou autre du segment au préalable
    flèche bas (1 ou n fois si on veut sauter des items) suivi de barre espace

  6. #6
    Membre averti
    Homme Profil pro
    Supply planner
    Inscrit en
    Août 2018
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Supply planner

    Informations forums :
    Inscription : Août 2018
    Messages : 23
    Par défaut
    Bonjour Chris ,

    Merci pour ton retour. Là est tout mon problème l'emploi des flèches + barre d'espace ou enter est trop long pour les 1000 références que je dois balayer pour contrôle. J'ai essayé quelque chose dans ce genre mais non fonctionnel...Le top serait d'avoir juste à utiliser les flèches pour faire défiler les réfs.
    En vous remerciant tous pour votre aide
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    Sub test1()
      Dim i As Integer, LR As Integer
     
      With ActiveWorkbook.SlicerCaches("Slicer_Article")
        LR = .SlicerItems.Count
        i = 0
        Do While i <> .SlicerItems.Count
                If .SlicerItems(i).Caption = newSelection Then .SlicerItems(i).Select
                SendKeys "{DOWN}"
            i = i + 1
        Loop
     
       End With
    End Sub

Discussions similaires

  1. Réponses: 2
    Dernier message: 09/08/2012, 13h34
  2. form Controle resize
    Par Walid(Tun) dans le forum VB.NET
    Réponses: 5
    Dernier message: 24/08/2010, 00h47
  3. Réponses: 1
    Dernier message: 04/03/2010, 16h08
  4. [Dojo] Modifier la largeur du select dans : Dijit / Form Controls / Filtering Select / Basic
    Par zied.ellouze dans le forum Bibliothèques & Frameworks
    Réponses: 2
    Dernier message: 04/05/2009, 13h16
  5. Hosting .NET Windows Forms Controls in IE
    Par AntonioMath dans le forum Windows Forms
    Réponses: 0
    Dernier message: 21/04/2009, 21h18

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