+ Reply to Thread
Results 1 to 25 of 25

Conditional Copy Data from One sheet to another workbook

  1. #1
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Conditional Copy Data from One sheet to another workbook

    I need to copy data from one sheet to another by following these conditions:
    1) User should select/browse for a file, from the opened file, it copies data from column A to Column D from sheet1
    2) Column A has unique numbers while column C & D has duplication, it should ignore duplicate.it copies only unique numbers in Column A and their respective data in column B, C & D
    3) It paste the Data in Dashboard file(main file) in sheet RawData at column AH to AK by looking into last used row
    Image: as shown in image, it should copy the highlighted data and ignore duplication

    I have written below code but it,s not according to my requirement, please help me
    Please Login or Register  to view this content.
    sample.PNG
    Attached Files Attached Files
    Last edited by Zahid0111; 03-15-2020 at 12:40 PM.

  2. #2
    Forum Guru Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2010 on Linux
    Posts
    11,975

    Re: Conditional Copy Data from One sheet to another workbook

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)

  3. #3
    Registered User
    Join Date
    02-23-2020
    Location
    France
    MS-Off Ver
    2019
    Posts
    44

    Re: Conditional Copy Data from One sheet to another workbook

    You wrote :
    Set wsDest = ThisWorkbook.Worksheets(1)
    which designates the Bherkund tab, not the RawData one. This is why your data is copied into the wrong place

    You should write:
    Set wsDest = ThisWorkbook.Worksheets("RawData")

    Good luck,
    --
    LR

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    Waiting for Moderator's request to be addressed.
    Last edited by Mumps1; 03-15-2020 at 01:19 PM.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    @Pepe Le Mokko
    Sorry for posting. I didn't see your post until I had already posted the macro.

  6. #6
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    ok thank you for guidance...i didnt knew this...next time wont happen. Link is below
    https://www.ozgrid.com/forum/index.p...48#post1232048
    https://www.mrexcel.com/board/thread.../#post-5447704
    Last edited by Zahid0111; 03-16-2020 at 09:29 AM.

  7. #7
    Forum Guru Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2010 on Linux
    Posts
    11,975

    Re: Conditional Copy Data from One sheet to another workbook

    Administrative note

    Please add links to ALL your cross-posts. there are AT LEAST one other.

    (Note: this requirement is not optional. No help to be offered until the links are provided.)
    Last edited by Pepe Le Mokko; 03-16-2020 at 09:26 AM.

  8. #8
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    done updated above reply

  9. #9
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    can you please release the answer..thanks

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    It looks like the OP has complied with the Moderator's request.

    In your source file, you have merged cells in column A. You should avoid using merged cells because they almost always create problems for macros. Before running the macro, unmerge the cells in column A and re-save the file.

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    Thankyou @Mumps1: i unmerged as you told me. but i need to copy only the highlighted data as shown in the picture(I got this data after running the macro in output file). Kindly check the attached pictureAttachment 667581
    Last edited by Zahid0111; 03-16-2020 at 12:41 PM.

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    The link to the picture doesn't work. Perhaps attach the file and highlight there.

  13. #13
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    okay now please check the attachments...yellow highlighted rows are only required please
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Zahid0111; 03-16-2020 at 12:49 PM.

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    Have a look at the attached file. I believe that the macro is returning the results you requested.
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    Yes it is working excellent...i have one request please... as highlighted in attached picture, can we remove the first ZERO from every number
    Attached Images Attached Images

  16. #16
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    Try:
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    Fantastic..Thank you so much...you are awesome..GOD BLESS YOU...

  18. #18
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    You are very welcome.

  19. #19
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    Hi, Sorry to disturb you once more. Actually today when i tried to use the above code by importing data from actual file, i m getting some extra row once again..can you please check this. I have highlighted extra rows in the picture plus attached is the original book from which i m importing data.
    Attached Images Attached Images
    Attached Files Attached Files

  20. #20
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    Currently your source file does not have any headers in A1:D1. Insert the headers and re-save and close the file. Then try this macro:
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    okay thank you..it,s now working again according to requirement. When it asks to select file, if i don,t import/select a file,i mean when i press cancel button, it gives the following error:
    Attached Images Attached Images

  22. #22
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    Try:
    Please Login or Register  to view this content.

  23. #23
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    5,503

    Arrow

    (removed as too late)

  24. #24
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Pakistan
    MS-Off Ver
    365
    Posts
    208

    Re: Conditional Copy Data from One sheet to another workbook

    Now that,s good...it,s working nicely...Thank you so much dear...

  25. #25
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,618

    Re: Conditional Copy Data from One sheet to another workbook

    My pleasure.

+ 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. [SOLVED] VBA: Copy Conditional Formatting from one sheet to another in the same workbook
    By devildogdad76 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-25-2019, 01:47 AM
  2. Copy Conditional Formatting from one sheet to another in the same workbook
    By devildogdad76 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-24-2019, 05:06 AM
  3. [SOLVED] Copy data from multiple WorkBook structures to the same sheet on another workbook
    By tax112 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-16-2018, 09:43 AM
  4. Copy data from one workbook to a specific sheet in another workbook without overriding
    By cdhampshire in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2017, 01:06 PM
  5. Replies: 6
    Last Post: 04-10-2013, 11:02 PM
  6. Conditional copy of a column in one sheet to another workbook transposed
    By gherzberg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2012, 08:49 AM
  7. Replies: 0
    Last Post: 08-11-2011, 01:23 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