+ Reply to Thread
Results 1 to 18 of 18

Copy data from one excel sheet to another based on condition

  1. #1
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Copy data from one excel sheet to another based on condition

    Hi all,
    I am having a new workbook with 2 sheets, where sheet1 contains the data as follows

    sheet1.png

    Now when I started changing cell in sheet1(Except first row which is ID), I need to do the following

    If there are no records in Sheet2 I need to create the columns with same headers of Sheet1
    I need to copy entire data from Sheet1 to shee2 based on active row of Sheet1 (means if I am doing modifications for the row2 then I need to save only that row to sheet2)
    If the same row already exists in sheet2 I want to replace the entire row with the current changes in sheet1

    Please check my word document where I have given scenarios how my requirement is
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Copy data from one excel sheet to another based on condition

    You should attach spreadsheets really.
    Attached Files Attached Files
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Copy data from one excel sheet to another based on condition

    Hi,
    Welcome to the forum.

    Please find the attached sheet and see if this is what you are trying to achieve.
    The code is present on Sheet1 Module.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Quote Originally Posted by mehmetcik View Post
    You should attach spreadsheets really.
    Perfect thanks mehmetcik

  5. #5
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Quote Originally Posted by sktneer View Post
    Hi,
    Welcome to the forum.

    Please find the attached sheet and see if this is what you are trying to achieve.
    The code is present on Sheet1 Module.
    Perfect thanks sktneer

  6. #6
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    One small question if I had more columns like address, phone number how can I make it in dynamic way for the same

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Copy data from one excel sheet to another based on condition

    post a sample spreadsheet and I will look at it for you.

  8. #8
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Here is the sample attached, in this I am having 3 columns like ID, Name, Address what I need is the macro that you have given should work for all the columns I am having.
    Attached Files Attached Files

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Copy data from one excel sheet to another based on condition

    Please find the attached sheet and see if this is what you are trying to achieve.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Quote Originally Posted by sktneer View Post
    Please find the attached sheet and see if this is what you are trying to achieve.
    Thanks sktneer, I will give it a try

  11. #11
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Copy data from one excel sheet to another based on condition

    Did you check the file attached in post#9?

  12. #12
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Quote Originally Posted by sktneer View Post
    Did you check the file attached in post#9?
    Yes but when I opened the document entire data should not get copied, sheets should be same as the original document but when I start editing data on any sheet then only that data should go to newly created one, like your solution for #3

  13. #13
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Quote Originally Posted by sktneer View Post
    Did you check the file attached in post#9?
    Yes but when I opened the document entire data should not get copied, sheets should be same as the original document but when I start editing data on any sheet then only that data should go to newly created one, like your solution for #3

  14. #14
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Copy data from one excel sheet to another based on condition

    Please find the attached sheet to see if this works now as per your expectations.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Quote Originally Posted by sktneer View Post
    Please find the attached sheet to see if this works now as per your expectations.
    Thanks sktneer this meets my requirement

  16. #16
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Copy data from one excel sheet to another based on condition

    You're welcome. Good to know that.

    If that takes care of your question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.

  17. #17
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Quote Originally Posted by sktneer View Post
    You're welcome. Good to know that.

    If that takes care of your question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.
    Done sktneer, thanks for helping

  18. #18
    Registered User
    Join Date
    04-19-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copy data from one excel sheet to another based on condition

    Hi I got one problem with the macro When I am having the same names and when editing the data instead of pasting it in original cell it was placing in another cell can you help me

+ 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. Replies: 0
    Last Post: 03-10-2014, 03:15 PM
  2. Need a macro to copy data from one sheet to another based on condition.
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-21-2013, 01:56 AM
  3. Copy data from all but a few worksheets into a summary sheet based on condition
    By d_kjellin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2013, 12:27 PM
  4. [SOLVED] Copy Data Range to another sheet based on a condition.
    By psunursingguy21 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-30-2013, 03:50 PM
  5. Copy data to another Excel based on condition
    By shreyjain in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-02-2012, 07:01 AM

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