Copier/Coller une colonne dans un Select/Case

shenmicke

XLDnaute Junior
Bonjour,
je cherche a copier coller une colonne dans un autre onglet.
Je copie colle dans l'onglet qui porte le nom de la ligne 9.

Code:
Sub Macro1()

Dim cmp As Integer, jb As Integer, nf As Integer, am As Integer, er As Integer, mb As Integer, hd As Integer, ag As Integer

cmp = jb = nf = am = em = hd = ag = 14

'***********************
'Organisation par noms
'***********************

Select Case (Cells(9, cmp).Value)

    Case "Julie B"
    
        Sheets("2012 FORECASTS TOTAL QUANTITE").Range(Cells(11, cmp), Cells(744, cmp)).Value = Sheets("Julie B").Range(Cells(11, jb), Cells(744, jb))
        jb = jb + 1
        cmp = cmp + 1
        
    Case "Nathalie F"
    
        Sheets("2012 FORECASTS TOTAL QUANTITE").Range(Cells(11, cmp), Cells(744, cmp)).Value = Sheets("Nathalie F").Range(Cells(11, nf), Cells(744, nf))
        nf = nf + 1
        cmp = cmp + 1
        
    Case "Alexis M"
    
        Sheets("2012 FORECASTS TOTAL QUANTITE").Range(Cells(11, cmp), Cells(744, cmp)).Value = Sheets("Alexis M").Range(Cells(11, am), Cells(744, am))
        am = am + 1
        cmp = cmp + 1

    Case "Elodie R"
    
        Sheets("2012 FORECASTS TOTAL QUANTITE").Range(Cells(11, cmp), Cells(744, cmp)).Value = Sheets("Elodie R").Range(Cells(11, er), Cells(744, er))
        er = er + 1
        cmp = cmp + 1
        
     Case "Marie-Laetitia B"
    
        Sheets("2012 FORECASTS TOTAL QUANTITE").Range(Cells(11, cmp), Cells(744, cmp)).Value = Sheets("Marie-Laetitia B").Range(Cells(11, mb), Cells(744, mb))
        mb = mb + 1
        cmp = cmp + 1

    Case "Hélène D"
    
        Sheets("2012 FORECASTS TOTAL QUANTITE").Range(Cells(11, cmp), Cells(744, cmp)).Value = Sheets("Hélène D").Range(Cells(11, hd), Cells(744, hd))
        hd = hd + 1
        cmp = cmp + 1


     Case "Audrey G"
    
        Sheets("2012 FORECASTS TOTAL QUANTITE").Range(Cells(11, cmp), Cells(744, cmp)).Value = Sheets("Audrey G").Range(Cells(11, ag), Cells(744, ag))
        ag = ag + 1
        cmp = cmp + 1
        
    Case Else
        End Select
        
        
        End Sub



Mon fichier est trop lourd même en zip pour vous le faire partager malheureusement :(

Merci

update : j'ai enlevé les noms mais garder les prénoms :p
 
Dernière édition:

shenmicke

XLDnaute Junior
Re : Copier/Coller une colonne dans un Select/Case

:confused:

donc nonsht et nomsht sont différents ? ou c'est une faute de frappe et il faut tout mettre en NomSht ?

Code:
Sub Macro1()
  Dim Cmp As Integer, DCol As Integer, NomSht As String
  ' Initialisation des variables
  Cmp = 14
  ' récupérer el nom
  NonSht = Cells(9, Cmp).Value
  ' Trouver la dernière colonne de la feuille
  DCol = Sheets(NomSht).Cells(1, Columns.Count).End(xlToLeft).Column
  ' Inscrire les données
  Sheets("2012 FORECASTS TOTAL QUANTITE").Range(Cells(11, Cmp), Cells(744, Cmp)).Value _
    = Sheets(NonSht).Range(Cells(11, DCol), Cells(744, DCol))
  Cmp = Cmp + 1
End Sub

En tout cas, ici y a une erreur d'indice :
DCol = Sheets(NomSht).Cells(1, Columns.Count).End(xlToLeft).Column
 

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
312 305
Messages
2 087 084
Membres
103 459
dernier inscrit
Arnocal