Find a column header, then copy and paste the column to a different location

carefreeant88

New Member
Joined
Nov 27, 2024
Messages
18
Office Version
  1. 2010
Platform
  1. Windows
Morning,

Thanks everyone for your help up until now. I have one last Macro/VBA that I would really do with some help with please! Basically, below is what I need to achieve:

  1. In the Workbook, go to the Worksheet called BP
  2. Search in the the BP Worksheet for the column called 'Article'
  3. If you find the column called 'Article', please select that whole column, and copy and paste it to column 'A' on the Worksheet called BP

    ***Please note that there will already data in column 'A'; so when copying and pasting the Article column, I basically need it to insert a new column to do the copy and paste; ie to avoid overwriting the data that is in column A***
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
please select that whole column, and copy and paste it to column 'A' on the Worksheet called BP
***Please note that there will already data in column 'A'; so when copying and pasting the Article column, I basically need it to insert a new column to do the copy and paste; ie to avoid overwriting the data that is in column A***
Your words are completely contradictory.o_O
 
Upvote 0
You want copy to column A and you said there is already data in column A , so why you want to copy to column A if you want the old data in column A?!! . you can select any column to avoid that.
 
Upvote 0
You want copy to column A and you said there is already data in column A , so why you want to copy to column A if you want the old data in column A?!! . you can select any column to avoid that.
I don't want to copy column A.

I want to copy the column called 'Article'.

And then effectively copy that into Column A.

There is already data in Column A, which I don't want to overwrite. So in essence - I assume - that the Macro would need to Insert a column to the left of Column 'A' in order to put the data I have copied from the column called 'Article'.
 
Upvote 0
ok
this is my try if I understand you correctly.
VBA Code:
Sub CopyGoods()
    Dim sr As Range

    Set sr = Sheets("BP").Rows(1).Find("Article")

    If sr Is Nothing Then
        MsgBox "Article column does not exists ", vbInformation, "Article word not found"
    Else
       Columns(1).Insert Shift:=xlToLeft

        sr.EntireColumn.Copy Sheets("BP").Range("A1")
    End If
    End Sub
 
Upvote 0
ok
this is my try if I understand you correctly.
VBA Code:
Sub CopyGoods()
    Dim sr As Range

    Set sr = Sheets("BP").Rows(1).Find("Article")

    If sr Is Nothing Then
        MsgBox "Article column does not exists ", vbInformation, "Article word not found"
    Else
       Columns(1).Insert Shift:=xlToLeft

        sr.EntireColumn.Copy Sheets("BP").Range("A1")
    End If
    End Sub
Thank you!!
 
Upvote 0
Your welcome.:)
and don't forget mark solved if this solved your question.;)
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top