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 :

Vba copie d'image


Sujet :

Macros et VBA Excel

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Assistante Qualité
    Inscrit en
    Janvier 2019
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Assistante Qualité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2019
    Messages : 14
    Par défaut Vba copie d'image
    Bonjour !

    J'ai fait un code (avec de l'aide) de la manière suivante mais les images ne se mettent pas dans la cellule que je souhaite.

    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
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("C9")) Is Nothing Then Call données
    End Sub
     
    Sub données()
     
     
    Dim Réf As String
    Dim x As Variant, y As Variant
    Dim WB As Worksheet, WFL As Worksheet
     
     
     
    Set WFL = ThisWorkbook.Worksheets("Fiche logistique")
    Set WB = ThisWorkbook.Worksheets("BASE")
     
    Range("B12:B20").ClearContents
    Range("B23:B30").ClearContents
    Range("B33:B45").ClearContents
     
     
    Réf = WFL.Cells(9, 2) & WFL.Cells(9, 3)
     
    With WB
        For x = 5 To .Range("A" & Rows.Count).End(xlUp).Row
            If .Cells(x, 5) & .Cells(x, 3) = Réf Then
            y = 6
            WFL.Cells(12, 2) = WB.Cells(x, y)
            y = 7
            WFL.Cells(13, 2) = WB.Cells(x, y)
            y = 8
            WFL.Cells(14, 2) = WB.Cells(x, y)
            y = 9
            WFL.Cells(15, 2) = WB.Cells(x, y)
            y = 10
            WFL.Cells(16, 2) = WB.Cells(x, y)
            y = 11
            WFL.Cells(17, 2) = WB.Cells(x, y)
            y = 12
            WFL.Cells(18, 2) = WB.Cells(x, y)
            y = 13
            WFL.Cells(19, 2) = WB.Cells(x, y)
            y = 14
            WFL.Cells(20, 2) = WB.Cells(x, y)
            y = 15
            WFL.Cells(23, 2) = WB.Cells(x, y)
            y = 16
            WFL.Cells(24, 2) = WB.Cells(x, y)
            y = 17
            WFL.Cells(25, 2) = WB.Cells(x, y)
            y = 18
            WFL.Cells(26, 2) = WB.Cells(x, y)
            y = 19
            WFL.Cells(27, 2) = WB.Cells(x, y)
            y = 20
            WFL.Cells(28, 2) = WB.Cells(x, y)
            y = 21
            WFL.Cells(29, 2) = WB.Cells(x, y)
            y = 22
            WFL.Cells(30, 2) = WB.Cells(x, y)
            y = 23
            WFL.Cells(33, 2) = WB.Cells(x, y)
            y = 24
            WFL.Cells(34, 2) = WB.Cells(x, y)
            y = 25
            WFL.Cells(35, 2) = WB.Cells(x, y)
            y = 26
            WFL.Cells(36, 2) = WB.Cells(x, y)
            y = 27
            WFL.Cells(37, 2) = WB.Cells(x, y)
            y = 28
            WFL.Cells(38, 2) = WB.Cells(x, y)
            y = 29
            WFL.Cells(39, 2) = WB.Cells(x, y)
            y = 30
            WFL.Cells(40, 2) = WB.Cells(x, y)
            y = 31
            WFL.Cells(41, 2) = WB.Cells(x, y)
            y = 32
            WFL.Cells(42, 2) = WB.Cells(x, y)
            y = 33
            WFL.Cells(43, 2) = WB.Cells(x, y)
            y = 34
            WFL.Cells(44, 2) = WB.Cells(x, y)
            y = 35
            WFL.Cells(45, 2) = WB.Cells(x, y)
     
            y = 36
            Set img = Nothing
                    For Each sh In WB.Shapes
                        If sh.TopLeftCell.Row = x And sh.TopLeftCell.Column = y Then
                            Set img = sh
                            Exit For
                        End If
                    Next sh
                    If Not img Is Nothing Then
                        img.Copy
                        WFL.Paste
                        Set sh = WFL.Shapes(1)
                        sh.Top = WFL.Cells(13, 5).Top
                        sh.Left = WFL.Cells(13, 5).Left
                    End If
     
            y = 37
            Set img = Nothing
                    For Each sh In WB.Shapes
                        If sh.TopLeftCell.Row = x And sh.TopLeftCell.Column = y Then
                            Set img = sh
                            Exit For
                        End If
                    Next
                    If Not img Is Nothing Then
                        img.Copy
                        WFL.Paste
                        Set sh = WFL.Shapes(2)
                        sh.Top = WFL.Cells(26, 5).Top
                        sh.Left = WFL.Cells(26, 5).Left
                    End If
     
            y = 38
            Set img = Nothing
                    For Each sh In WB.Shapes
                        If sh.TopLeftCell.Row = x And sh.TopLeftCell.Column = y Then
                            Set img = sh
                            Exit For
                        End If
                    Next
                    If Not img Is Nothing Then
                        img.Copy
                        WFL.Paste
                        Set sh = WFL.Shapes(3)
                        sh.Top = WFL.Cells(37, 5).Top
                        sh.Left = WFL.Cells(37, 5).Left
                    End If
     
     
            End If
        Next
    End With
    End Sub
    Je vous explique mon fichier, je choisis en B9 une marque et en C9 un produit, lorsque que mon code cherche dans ma feuille BASE, il vient m'importer les valeurs trouvées.

    Pour les images, ça fonctionne très bien lorsque je choisis le premier produit de ma BASE
    (liste en B9 + C9 à sélectionner = REF)

    Mais lorsque je choisis un autre produit les images se mettent n importe où...


    Auriez-vous une idée ? j'aurai besoin d'aide ... (en PJ mon fichier)

    Merci,
    Clem
    Fichiers attachés Fichiers attachés

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. VBA 'copie de fiers excel ou access
    Par VBBBA dans le forum Macros et VBA Excel
    Réponses: 22
    Dernier message: 02/07/2006, 18h17
  2. [VBA-E] insertion images existante dans le classeur
    Par Ania dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 27/03/2006, 23h50
  3. VBA : copier une image d'une feuille excel à une autre
    Par Equus dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 08/12/2005, 14h01
  4. [Sécurité] Bloquer la copie d'images
    Par Pascal Lob dans le forum Langage
    Réponses: 6
    Dernier message: 14/10/2005, 22h29
  5. [VBA] Copie d'une feuille (avec graphique)
    Par ed_dexia dans le forum Macros et VBA Excel
    Réponses: 6
    Dernier message: 06/10/2005, 09h56

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