Results 1 to 8 of 8

Thread: Copy Data from tow sheets and pasting in third sheet

  1. #1

    Post Copy Data from tow sheets and pasting in third sheet



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I have a excel with 3 sheets .
    My requirement is to pull data from sheet1 ,sheet2 and put it into sheet3.
    There would be two headings in sheet 3 1)Active which would pull records from sheet1 and put it under it.
    2) Inactive which would pull records from sheet2 and place it under Inactive cell
    First it would populate from sheet1 to sheet3 under Active cell and then it should pull data from sheet2 and put in under inactive cell.

    Please advise as I am new to VBA.
    Thanks

  2. #2
    Conjurer Simi's Avatar
    Join Date
    Feb 2012
    Location
    Utah, USA
    Posts
    187
    Articles
    0
    can you upload a sample workbook of what you expect this to look like, and to show the data you have.

    For example, is data only in column A on both sheet1 and sheet2?

  3. #3
    Please find my sample worksheet attached.Appreciate your help and would be thankful in giving me directions.
    Attached Files Attached Files

  4. #4
    Conjurer Simi's Avatar
    Join Date
    Feb 2012
    Location
    Utah, USA
    Posts
    187
    Articles
    0
    depending on how much data you have or if you end up with more columns you may need something different.

    But this should work with the sample you provided.

    Code:
    Sub simi_copy()
    
    
    Worksheets("Active").Range(Worksheets("Active").Cells(2, 1), Worksheets("Active").Cells(Worksheets("Active").Cells(Worksheets("Active").Rows.Count, "A").End(xlUp).Row, 3)).Copy _
        Destination:=Worksheets("Final").Cells(Worksheets("Final").Cells(Worksheets("Final").Rows.Count, "A").End(xlUp).Row + 1, 1)
    Worksheets("Inactive").Range(Worksheets("Inactive").Cells(2, 1), Worksheets("Inactive").Cells(Worksheets("Inactive").Cells(Worksheets("Inactive").Rows.Count, "A").End(xlUp).Row, 3)).Copy _
        Destination:=Worksheets("Final").Cells(Worksheets("Final").Cells(Worksheets("Final").Rows.Count, "A").End(xlUp).Row + 1, 1)
    
    
    End Sub

  5. #5
    will this automatically copy the all data retrieved in both sheets and paste it on the third sheet?
    First the data from sheet 1 and then from sheet 2?

    Please give your valuable inputs and would really helpful for a novice like me

  6. #6
    Conjurer Simi's Avatar
    Join Date
    Feb 2012
    Location
    Utah, USA
    Posts
    187
    Articles
    0
    The way this is setup, it will copy all the data from cell "A2" to cell "C(bottom row with data)" from the "Active" sheet, and paste it to sheet3 "Final".
    Then it will copy all the data from "Inactive" in the same way and paste to "Final"

    If you run this macro more than once, it will append the data to the bottom of sheet3, So in your example book, you only had 1 record on each of the first 2 sheets.
    so sheet3 would end up with 2 records on it. if you run the macro again sheet3 would have 4 records on it.

    It is simple and effective.

  7. #7
    Thank you so much Simi.

    Another questions can I copy some of the columns from Inactive sheet and paste it under some columns in Final sheet.

    This I want after I copy all data from active to final sheet .
    I know I am asking too much but as I am noviec I would need your advice.

  8. #8
    Conjurer Simi's Avatar
    Join Date
    Feb 2012
    Location
    Utah, USA
    Posts
    187
    Articles
    0
    I'm not sure what you are asking now.

    The code above copies all data from active to final, then all data from inactive to final.

Posting Permissions

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