+ Reply to Thread
Results 1 to 9 of 9

Vba code to extract specific data from pdf file and insert it in an excel sheet

  1. #1
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Vba code to extract specific data from pdf file and insert it in an excel sheet

    Hi Everyone ,

    I receive a pdf file received that needs to be breakdown for specific case box use to extract tax values.

    Note as per pdf sample file ,Box 40 tax base code varies depending on box 27 commodity code

    Attached sample of expected results .

    So far what I have tried through acrobat reader and power query but did not give the expected results .

    Actually ,doing it manually which is very tedious

    But so far using also a converter but still unsuccessful to extract pdf table.

    Can anyone assist throught a vba code to extract the requested box data in excel format.
    Attached Files Attached Files

  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,215

    Re: Vba code to extract specific data from pdf file and insert it in an excel sheet

    You need to provide a converted (PDF-to-Excel) file as the output from convertors varies and hence the VBA will be tailored to a spciefic file format.
    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
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: Vba code to extract specific data from pdf file and insert it in an excel sheet

    Quote Originally Posted by JohnTopley View Post
    You need to provide a converted (PDF-to-Excel) file as the output from convertors varies and hence the VBA will be tailored to a spciefic file format.
    here a sample I could do , Hopes it helps
    Attached Files Attached Files
    Last edited by JEAN1972; 10-02-2023 at 11:23 AM. Reason: upload better sample excel file

  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,215

    Re: Vba code to extract specific data from pdf file and insert it in an excel sheet

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    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,215

    Re: Vba code to extract specific data from pdf file and insert it in an excel sheet

    Annotated code ...

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: Vba code to extract specific data from pdf file and insert it in an excel sheet

    Thanks John working as requested but my only trouble is when converting pdf to excel it seems the cells moves. which creates blank columns.

    Is there a way to troubleshoot this, I suspect that conversion are not same despite using original pdf file 2nd different file attached with the test done

    I used able2extract for the conversion pdf to excel.

    See attached the results getting some columns empty but tax compilation are ok , but just one tax code i missed from another pdf file converted , need to be adjusted

    Amount Payable Tax 49, i added .
    Attached Files Attached Files

  7. #7
    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,215

    Re: Vba code to extract specific data from pdf file and insert it in an excel sheet

    Please Login or Register  to view this content.
    If the conversion continues to be inconsistent, then the VBA will not work.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: Vba code to extract specific data from pdf file and insert it in an excel sheet

    I will try and advise but am trying to find a more stable converter pdf to excel as it seems to be inconsistent during the conversion despite having original pdf .

  9. #9
    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,215

    Re: Vba code to extract specific data from pdf file and insert it in an excel sheet

    The "problem" with latest was the "33 FOB Fcy" entry where the associated value is offset - first by one column and then by two in your last posted file.

    For all other entries, excluding the tax values, values are a row below the heading so are easy to match. The code uses row/column offsets to find the value hence the wrong value was returned using the initial code.

    With "33 FOB Fcy" the value is below cell containing "CC" so this could be used as a match BUt the VBA code then becomes a little messier!

+ 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] Extract specific data from .txt file and put it into worksheet excel
    By Lebbersmurf in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-27-2020, 10:22 AM
  2. [SOLVED] VBA code to browse for external excel file and extract its all sheet to current workbook
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2016, 04:05 AM
  3. Replies: 3
    Last Post: 12-18-2014, 10:27 AM
  4. [SOLVED] Extract specific data from a sheet created by a non-expert Excel user
    By gak67 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 06-18-2014, 12:00 AM
  5. Replies: 0
    Last Post: 06-11-2014, 03:10 AM
  6. Search for Excel file and the sheet within that from the given table data and extract data
    By adrian_slash in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-23-2013, 07:55 AM
  7. extract specific data from Excel Sheet
    By chfahadjavaid in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-27-2013, 03:11 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