+ Reply to Thread
Results 1 to 19 of 19

Import data from one workbook to another(Search for specific sheets for copy and paste)

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

    Import data from one workbook to another(Search for specific sheets for copy and paste)

    I have two excel files, One excel file is named as Dashboard and in which i have inserted "Import Data" button. I want, when i click this button it should bring the import/Browse/Select file window by using command Application.GetOpenFilename. An excel file will be selected and in this file it should search/look for Sheet named "Grade Wise"and copy all data (from column A to column E). This data to be pasted in dashboard workbook(where we have inserted the import button).It will search for Sheet named"RawData" and paste data in last blank row(Column A to Column E). I need VBA code for this operation please help me
    Attached Files Attached Files
    Last edited by Zahid0111; 03-11-2020 at 10:45 AM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Is it what you want
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by PCI; 03-11-2020 at 03:41 AM. Reason: Code updated with sheet test
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Completely different method.
    Read data from closed workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Hi thanks it,s working great..thank you so much...Now after copying data i want to run a code(which is attached and included in file) whose function is to Seperate First alphabets of columns C(Grade).
    As Columns C(Grade) has different grades whose starting alphabets are X, C,M,B and their third alphabets includes A,F,C also.
    CHALLENGE 1: Now, i want to copy sum of all X to X (on same sheet column K), sum of all C to C(on Same sheet Column L), sum of all M to M (on same sheet Column M) and sum of all B to B (on Same sheet Column N) for each unique number(Farmer Number).
    CHALLENGE 2: From ColumnC(Grade),It should also look for third alphabet(A,F,C) and copy their Sum of all A to A (on same sheet column U), Sum of all F to F (on 3rd sheet column V), Sum of all C to C (on 3rd sheet column W) as shown in attached pictures I need VBA code for this operations please help me.
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Hi thanks it,s working great..thank you so much...Now after copying data i want to run a code(which is attached and included in file) whose function is to Seperate First alphabets of columns C(Grade).
    As Columns C(Grade) has different grades whose starting alphabets are X, C,M,B and their third alphabets includes A,F,C also.
    CHALLENGE 1: Now, i want to copy sum of all X to X (on same sheet column K), sum of all C to C(on Same sheet Column L), sum of all M to M (on same sheet Column M) and sum of all B to B (on Same sheet Column N) for each unique number(Farmer Number).
    CHALLENGE 2: From ColumnC(Grade),It should also look for third alphabet(A,F,C) and copy their Sum of all A to A (on same sheet column U), Sum of all F to F (on 3rd sheet column V), Sum of all C to C (on 3rd sheet column W) as shown in attached pictures I need VBA code for this operations please help me.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    If you just want to run "test2" then add one line at the end of my code.
    Please Login or Register  to view this content.

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    I tried running your code by selecting another sheet which has data in Column F, G, H too and it copied that data and pasted in RawData sheet...I need to copy data just from Column A to Column E to RawData sheet. Can you please make the changes

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Attachment 666797Attachment 666799

    Hi after adding above code, i gives me the attached error.please look into this

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Your attachment says "invalid".

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Attachment 666804
    Attachment 666805
    please check them now or i m sending main file too..
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Quote Originally Posted by Zahid0111 View Post
    I tried running your code by selecting another sheet which has data in Column F, G, H too and it copied that data and pasted in RawData sheet...I need to copy data just from Column A to Column E to RawData sheet. Can you please make the changes
    1) Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    2) Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Yes it is now only copying the required columns..thanks great..
    can you please check the other error, for which i sent the attachments too

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    You are adding the code, not changing the code.
    Please Login or Register  to view this content.
    Last edited by jindon; 03-11-2020 at 09:50 AM.

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Attachment 666815
    Actually i added this code to run test() as you advised, but it gives me error, can you please check the errors in the workbook attached
    Attachment 666816
    Attachment 666817
    Attached Files Attached Files

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    I added the code(Highlighted BOLD) as given below
    Please Login or Register  to view this content.
    Last edited by Zahid0111; 03-11-2020 at 09:50 AM.

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Read my post #11 carefully.

    I have not said "add", I said "change" the line.

    The last code I posted is already changed, so use it.

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Dear, i used it but error is coming from the code which i provided, kindly check it why it shows this error. attached are the screenshots along with workbook please
    Attachment 666824Attachment 666825
    Attached Files Attached Files

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    1) All your attachments are invalid, so stop it.

    2) My code is working, but "test2" is throwing the error.
    I don't really want to touch the code written by someone else, but sheet reference is strange.
    Please Login or Register  to view this content.
    I don't use sheet index if the sheet name is known.
    Perhaps
    Please Login or Register  to view this content.
    Otherwise ask to the person who wrote the code.

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

    Re: Import data from one workbook to another(Search for specific sheets for copy and paste

    Ok Great Thank you so much for your kind help...i really appreciate for your kind time and effort

+ 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 for copy/paste specific cells from several sheets into a master data workbook
    By BalanF in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-07-2018, 09:01 AM
  2. Replies: 3
    Last Post: 02-16-2018, 06:40 PM
  3. [SOLVED] macro to copy in loop all sheets at specific row and paste in a new workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-01-2018, 03:04 AM
  4. [SOLVED] Search, Select, Copy, and Paste Specific Data
    By stpeter in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-08-2015, 11:10 AM
  5. Search, Copy and paste specific field from one workbook to another
    By CARRpeter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-10-2012, 11:16 PM
  6. Replies: 0
    Last Post: 11-19-2009, 09:20 AM
  7. macro to copy specific data from one sheet and paste into two sheets
    By Shogun in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2009, 04:56 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