VBA copie cellule vers autre classeur

Bonjour,

Je souhaiterai copier les valeurs des cellules AA4:AA24 de chaque onglet du classeur "recup h mois" vers les cellules C9 à C29 de chaque onglet respectif du classeur TR

Merci pour votre aide

Bonjour Idma,

Bonjour le Forum,

Si tes deux classeurs sont ouverts, alors tu peux utiliser le code ci-dessous :

Sub CopyPaste()
Dim wh, wh2 As Workbook, x As Long
Set wh = Workbooks("RECUP H MOIS.xlsm")
Set wh2 = Workbooks("Commande TR_IS2.xlsm")
For x = 1 To 12
    wh2.Sheets(x).Cells(9, 3) = wh.Sheets(x).Cells(4, 27)
    wh2.Sheets(x).Cells(10, 3) = wh.Sheets(x).Cells(5, 27)
    wh2.Sheets(x).Cells(11, 3) = wh.Sheets(x).Cells(6, 27)
    wh2.Sheets(x).Cells(12, 3) = wh.Sheets(x).Cells(7, 27)
    wh2.Sheets(x).Cells(13, 3) = wh.Sheets(x).Cells(8, 27)
    wh2.Sheets(x).Cells(14, 3) = wh.Sheets(x).Cells(9, 27)
    wh2.Sheets(x).Cells(15, 3) = wh.Sheets(x).Cells(10, 27)
    wh2.Sheets(x).Cells(16, 3) = wh.Sheets(x).Cells(11, 27)
    wh2.Sheets(x).Cells(17, 3) = wh.Sheets(x).Cells(12, 27)
    wh2.Sheets(x).Cells(18, 3) = wh.Sheets(x).Cells(13, 27)
    wh2.Sheets(x).Cells(19, 3) = wh.Sheets(x).Cells(14, 27)
    wh2.Sheets(x).Cells(20, 3) = wh.Sheets(x).Cells(15, 27)
    wh2.Sheets(x).Cells(21, 3) = wh.Sheets(x).Cells(16, 27)
    wh2.Sheets(x).Cells(22, 3) = wh.Sheets(x).Cells(17, 27)
    wh2.Sheets(x).Cells(23, 3) = wh.Sheets(x).Cells(18, 27)
    wh2.Sheets(x).Cells(24, 3) = wh.Sheets(x).Cells(19, 27)
    wh2.Sheets(x).Cells(25, 3) = wh.Sheets(x).Cells(20, 27)
    wh2.Sheets(x).Cells(26, 3) = wh.Sheets(x).Cells(21, 27)
    wh2.Sheets(x).Cells(27, 3) = wh.Sheets(x).Cells(22, 27)
    wh2.Sheets(x).Cells(28, 3) = wh.Sheets(x).Cells(23, 27)
    wh2.Sheets(x).Cells(29, 3) = wh.Sheets(x).Cells(24, 27)
Next
End Sub

Si l'un des deux n'est pas ouvert au moment où le code est lancé, alors reviens vers nous.

NB : La méthode de copie multiple échoue en raison du format utilisé avec les tableaux du classeur "Commande TR_IS2.xlsm"

D'où l'utilisation de la Boucle

A dispo

ça marche merci

Un plaisir! N'oublie pas :

Rechercher des sujets similaires à "vba copie classeur"