Copy columns by headers
Solved
alberkrimo
Posted messages
20
Status
Member
-
alberkrimo Posted messages 20 Status Member -
alberkrimo Posted messages 20 Status Member -
Hello,
I am reaching out to you hoping to get some help. As a beginner in VBA, I am using a code to search for a column in one sheet and then copy and paste it into another sheet. This code allows me to search for only one column at a time.
What I want to do is select multiple different columns based on their headers.
Does anyone have a code for that?
The code is as follows:
Thank you in advance.
Best regards.
I am reaching out to you hoping to get some help. As a beginner in VBA, I am using a code to search for a column in one sheet and then copy and paste it into another sheet. This code allows me to search for only one column at a time.
What I want to do is select multiple different columns based on their headers.
Does anyone have a code for that?
The code is as follows:
Sub Col_Select() Dim Cel As Range Set Cel = Cells.Find(what:="Bât") If Not Cel Is Nothing Then Cells(1, Cel.Column).Resize(Cells(Rows.Count, Cel.Column).End(xlUp).Row).Select Else MsgBox "Not found the name " Exit Sub End If End Sub
Thank you in advance.
Best regards.
2 answers
-
Hello,
Where are you with this request, as I have not received a response from you?
https://forums.commentcamarche.net/forum/affich-34305471-capacite-combobox
For copying columns, naming the columns to copy would make it simpler
you would have a code like this, copy column D and H to L and MSub Macro2() Range("Col_D" & "," & "Col_H").Copy Range("L1") End Sub -
Hello,
An example to adapt.
.Row can be replaced by .Column (for example)...
--
Before, I never managed to finish my sentences... but now I-
https://www.cjoint.com/c/GAEkNhdRk5k
Here is an example. I would like to copy column A "Request Number" and B "Status", knowing that these two columns will change next week.
I cannot adapt your code. I'm not very good at VBA.
Can you help me please?
Thank you- For this, your code provided in the first message is enough.
It's up to you to adapt it by doing it twice...Sub Col_Select() Dim Cel As Range Set Cel = Rows(1).Cells.Find(what:="Request Number") If Not Cel Is Nothing Then 'HERE copy/paste code Else MsgBox "Request Number not found" End If Set Cel = Rows(1).Cells.Find(what:="Status") If Not Cel Is Nothing Then 'HERE copy/paste code Else MsgBox "Status not found" End If End Sub
-
-