• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

copy columns

Marie30

New Member
Hello everyone,
I have a vba code that copies the columns according to the request of the user,
The choice of columns to copy is done with an inputbox, the column separator is the comma (,).
The code works but does not fully answer my request, it copies the columns from the column "B" or I wish that the copies of the columns start from the column "A".
Thank you for your answers.
As mother tongue is French, here is my request in French.
Bonjour à tous,
J’ai un code vba qui copie les colonnes selon la demande de l’utilisateur,
Le choix des colonnes à copier se fait avec un inputbox, le séparateur des noms des colonnes est la virgule (,).
Le code fonctionne mais ne répond pas totalement à ma demande, le code copie les colonnes à partir de la colonne "B" or je souhaite que les copies des colonnes se fait à partir de la colonne "A".
Merci de vos réponses
 

Attachments

  • Copie_Des_Colonnes.xlsm
    27 KB · Views: 2
How about
Code:
Sub ChoisirLesColonnesEtLesCopier()
    

Colonne = InputBox("Saisissez la lettre des colonnes séparée d'une virgule comme suit par exemple: A,C,B,J", "Colonnes à recopier", "A,C,B,J")
 On Error Resume Next
 For i = 0 To UBound(Split(Colonne, ","))
 If Sheets("Sheet2").Range("A1") = "" Then
   Sheets("Sheet1").Columns(Split(Colonne, ",")(i)).Copy Sheets("Sheet2").Range("A1")
 Else
   Sheets("Sheet1").Columns(Split(Colonne, ",")(i)).Copy Sheets("Sheet2").Range("IV1").End(xlToLeft).Offset(0, 1)
 End If
 Next
End Sub
 
Hello Fluff13 and the Forum,
Thank you for the quick reply.
I tested the code, it is perfect and satisfies me.
Congratulations and thank you again.
 
Marie30
Am I late? Gotta eat too.
Check this ...
Why You would like to write column-letters?
Could You select the 1st row cell to 'mark' wanted columns to handle? I left there some selections...
With [ swap ], You could swap selections
With [ copy ], You could copy selected columns to Sheet2 (oldies will clear)
With [ add ], You could add selected column to Sheet2 (oldies will clear if needed),
selected column would fill from as left as possible - You could add more column - You could select any order of copied column.
 

Attachments

  • Copie_Des_Colonnes.xlsm
    26.7 KB · Views: 3
Hello vletm, Marc and the forum,
Thank you for your interventions.
In response to vletm, your code works very well, thank you very much, congratulations for your knowledge, what talent!
In response to Marc, thank you for your intervention, it is true that space is just as good.
Friendships to all 2.

Voici la réponse en Français :
Bonjour vletm, Marc et le forum,
Merci pour vos interventions.
En réponse à vletm, votre code fonctionne très bien, merci beaucoup, bravo pour vos connaissances, quel talent !
En réponse à Marc, merci pour cotre intervention, c’est vrai que l’espace fait aussi bien l’affaire.
Amitiés à tous les 2.
 
Back
Top