+ Reply to Thread
Results 1 to 4 of 4

Macro to Copy and paste data based on column headings

  1. #1
    Registered User
    Join Date
    04-09-2018
    Location
    UK
    MS-Off Ver
    2010
    Posts
    2

    Macro to Copy and paste data based on column headings

    Hi

    I'm very new to writing Macros in Excel, and have done a bit of looking around to try and solve my problem, but I haven't found a solution yet that works.

    I'm trying to write a Macro to do the following:

    I'm trying to copy data from Sheet 1, Workbook 1 based on column headings (so for example, I want to copy all the data under the column name "Sort"). The number of rows of data in this row may increase/decrease. I then want to paste this data into Sheet 2, Workbook 2 under the column name "Name". Columns may be added/removed from both workbooks, which is why I want to write the macro to copy based on the column name rather than a column number.

    I have been using the below code, which I've tried putting together based on similar but slightly different requests I've found online, but when I run the macro, nothing much happens - I've written the Macro in Workbook 2 and it just opens Workbook 1.

    If anyone can see something wrong with my code or suggest an alternative, I'd be extremely grateful for any help. Thanks!!!



    Please Login or Register  to view this content.
    Last edited by AliGW; 04-09-2018 at 02:49 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Macro to Copy and paste data based on column headings

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    As this is your first post, I'll do it for you this time. Please do read the forum rules as soon as possible.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-09-2018
    Location
    UK
    MS-Off Ver
    2010
    Posts
    2

    Re: Macro to Copy and paste data based on column headings

    Hi Ali. Sorry for this! Thanks for correcting for me.

  4. #4
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Macro to Copy and paste data based on column headings

    Hi @nw201827
    You can try this code.
    It copies all data in column "Sort" from the first book and pastes under title of column "Name" in second book

    Please Login or Register  to view this content.
    Barriers are there for those who don't want to dream

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Macro - Copy and paste data match by column headings
    By weijianhk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-26-2015, 11:05 PM
  2. macro to copy paste data based on column headings
    By kets0985 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-22-2014, 02:26 PM
  3. Create macro to copy data using column headings
    By zkhan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2013, 02:01 AM
  4. Macro to match column headings and paste into next available row.
    By vizzy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2013, 10:38 AM
  5. Copy/Paste filtered data from one sheet to another with only matched column headings
    By archerrc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-08-2013, 05:00 PM
  6. Macro to copy and paste based on a column
    By Mahitha in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2011, 04:48 AM
  7. [SOLVED] Macro Syntax to copy and paste dynamic data based on one column
    By jbsand1001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-17-2005, 10:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1