+ Reply to Thread
Results 1 to 7 of 7

Excel macro to copy data from Sheet1 row into Sheet2 column

  1. #1
    Registered User
    Join Date
    10-11-2011
    Location
    malaysia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Excel macro to copy data from Sheet1 row into Sheet2 column

    Hi

    Nice to meet you all here. I am a newbie in vb and also a new member to Excel Forum.
    I have encountered some difficulties in creating macro in excel where I need to copy data from Sheet1 row A1:C3 into Sheet2 column A1:C3 as well. Which means Sheet1 is a table whereas Sheet2 is a form. The idea now is to copy the data horizontally(row) become vertically(column) in each wordsheet respectively. Attached is the sample showing the simple requirement. Appreciate helps from anyone. Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Excel macro to copy data from Sheet1 row into Sheet2 column

    This is done so fast with a cut/paste, I'm not sure it's worth writing a macro for.

    1) Highlight the data on sheet2 A2:C???? (???? can be as far down as your data goes)
    2) Copy
    3) Switch to Sheet1 and click on B1
    4) Do an Edit > Paste Special > Transpose

    That could be recorded into a reusable macro in seconds. Just select a range on Sheet2 that goes down far enough to cover your future needs, 100-200 rows, perhaps?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    10-11-2011
    Location
    malaysia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Excel macro to copy data from Sheet1 row into Sheet2 column

    Hi

    Appreciate your fast response. I understand that it can be done simply just copy and paste the records from Sheet1 to Sheet2. However, it required a button (eg: Display) in worksheet "Form" which it will auto populate the mass data from "Table" worksheet into 'Form" worksheet whereby the aligment will be from row to column/horizontally to vertically. (Sorry if I didn't stated clearly in the first place).
    Thanks.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Excel macro to copy data from Sheet1 row into Sheet2 column

    Based on your sample, I don't think I misunderstood. You can record the steps I've suggested into a macro in seconds, then attach that macro to a button. Your example workbook and followup post have not added information to indicate a transposing cut/paste won't work just fine, even in a macro form.

  5. #5
    Registered User
    Join Date
    10-11-2011
    Location
    malaysia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Excel macro to copy data from Sheet1 row into Sheet2 column

    Hi

    Thanks for you patience and further guidance. I got your information. =)
    However, I encountered another 2 issues:
    i) When I assigned macro to the "Display Records" button, once I click on it, the alignment of the data populated in the form seems has not been transposed.
    ii) When I recording the macro, I have left some spaces for the button on top of the form so that the record populated is at the next subsequent rows. However, when I assigned the macro to the button and click on the button for testing, the data populated seems started from A1 onwards automatically.

    Appreciate your help and looking forward hearing from you soon. Thanks.

  6. #6
    Registered User
    Join Date
    10-11-2011
    Location
    malaysia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Excel macro to copy data from Sheet1 row into Sheet2 column

    Sorry, please see the attachment of what I have done and it shows the matters that I concerned. Thanks.
    Attached Files Attached Files

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Excel macro to copy data from Sheet1 row into Sheet2 column

    The macro you recorded (?) does not appear to have followed the instructions post #2 at all. I don't see where you activated the Paste Special function anywhere. I recorded one for you, but that, unfortunately, doesn't really teach you to do what I was trying to show you. You should keep trying to ensure you find and get familiar with the Paste Special options.

    I also returned this sheet back to its original format, then tweaked the recorded macro to:

    1) always get the number of rows from the "table" that you've filled out, regardless of how many
    2) always paste on the Form in the next empty column, wherever that may be

    So, try clicking the button more than once...
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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