+ Reply to Thread
Results 1 to 21 of 21

Copying data from Notepad to excel using VBA-NEED HELP

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

    Post Copying data from Notepad to excel using VBA-NEED HELP

    Hello team,

    I have almost 600 pages of PDF from which i copied the data to notepad(to make it easy to copy to excel). I want to copy specific data from notepad to excel sheet. I have written VBA code but its not working. Below is the code and attached are the screenshots along with the files for reference(sample data).

    It should only copy highlighted data from each line, highlighted for understanding purpose the same goes for all the data.
    notepad data.PNG

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Zahid0111; 10-26-2023 at 06:55 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Please add samples expected results to "Data.xlsm".
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Yes i have added sample data to Data.xlsm for your reference please
    Expected result snapshot
    expected.PNG
    Last edited by Zahid0111; 10-26-2023 at 07:48 AM.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    The issue is there is no easy way of identifying and separating data associated with a given heading on a line.

    A PDF might actually be more useful.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    okay let me add the same PDF file, data starts from page#28

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    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: Copying data from Notepad to excel using VBA-NEED HELP

    Hi jindon,
    Thanks for the code, it gives error
    Attachment 847368

    I have made some changes in the code, its working now but not copying all the data, can you please check, new code is given as:
    Please Login or Register  to view this content.
    Last edited by Zahid0111; 10-26-2023 at 10:05 AM.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Upload the workbook that gives the error and source text file.
    I posted the code after I tested and no error here.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Jindon, i am uploading txt file(with partial data) and workbook. i am building this txt file from pdf file which i have already uploading in the thread. it does not copies complete data, can you please check, as i will be adding all the data from pdf to txt file.
    It is also skipping data as highlighted in the picture below, it looks for only "TO BE REMOVED"
    2.PNG

    I have manually copy and pasted data as shown in below picture, it should be like this, since i have 600+ pages and cant be done manually. Need to be done through vba.
    example.jpeg
    Attached Files Attached Files
    Last edited by Zahid0111; 10-26-2023 at 11:50 AM.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    I need to see your desired result in WORKBOOK, not picture.
    Picture doesn't help, and make sure your result is CORRECT.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    I am attaching manually copied data to this excel file to help you understand my desired results(just a small portion) since its quite difficult to copy manually from txt file. I am copying data from PDF(starting from page 28) to txt file and then from txt to excel.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Try

    Please Login or Register  to view this content.
    I copied text file to Excel (sheet "Data")
    Attached Files Attached Files
    Last edited by JohnTopley; 10-27-2023 at 01:10 AM. Reason: Added 2 code lines

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Hi John Topley, Yess its working very fine. thank you . so if i copy whole data from pdf to notepad and then from notepad to excel(Data sheet), will it work for the whole data as the pdf contains 600 plus sheets?? need your kind guidance please..

  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    It should work for contents of 600 sheets (15000 rows approximately) so copy from Notepad to sheet "Data" and run the macro.

    Just hope your sample is typical as the macro has a few "work-arounds" for anomalies in the data: it is possible there may be others.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Okay great thank you, i will copy data from PDF to Text file tomorrow since its going to take time, than i will post here, if there is any anomaly i will let you know. if no issue is observed i will close this thread. Thank you once again..+1 adding as well.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    If any rows are different from your result, fill the cell with what you expect and color the them, so that I can see what you are really trying to do.
    Please Login or Register  to view this content.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    @jindon Thank you its working fine but need a little tuning. +1 to you..
    As i told you earlier that its a pdf file having 600 plus pages, the program copies and paste data to certain limit. i am attaching text file where it don,t copy the data, i am sending only that specific part which is not been copied, can you please check.
    Attached Files Attached Files

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    As I said, I need to see your desired result out of your last txt file.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Hi Jindon, uploaded excel file with sample results required
    Attached Files Attached Files

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    See if this works,
    Please Login or Register  to view this content.

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

    Re: Copying data from Notepad to excel using VBA-NEED HELP

    Thankyou @jindon. Its working fine. marking thread as resolved
    Thankyou JohnTopley as well
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

+ 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. Not copying Excel to Notepad as CSV format
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-08-2021, 08:29 PM
  2. [SOLVED] Copying and Pasting Data from Excel to Notepad
    By JSH2017 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2018, 01:08 PM
  3. Opening Notepad a saved notepad file and copying the data on it
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2014, 06:18 PM
  4. Copying more than one range of data from excel into more than one notepad file
    By brianQ in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 01:25 PM
  5. Copying Time from Notepad to Excel
    By CindyLisa in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-23-2011, 09:07 AM
  6. Copying the data from two notepad files to an Excel workbook
    By raghunaik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2009, 12:17 AM
  7. copying data from excel into notepad
    By walid66 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-19-2007, 03:58 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