+ Reply to Thread
Results 1 to 21 of 21

Need help removing "bad" data from Excel File that is exported from a PDF daily

  1. #1
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Need help removing "bad" data from Excel File that is exported from a PDF daily

    Hi All,

    I receive an excel file daily that is exported from a PDF (unfortunately there isn't another way) and I am hoping that someone can assist me with cleaning this up using VBA. The file has headers on each page that are not needed, my issue is that the exporting process never exports the file the same way (sometimes there are 8 rows on the header and sometimes there are 9 or 10. I do know that if there is a date "dd/mm" in column H that the line can stay and that if column K is blank it can be removed. I am hoping that someone can help me use those variables to automatically clean the sheet so that I don't spend 20-30 minutes every day removing all of the unneeded data.

    What I know:

    If column H has a date and column K has data- keep
    If column H has a date and column K is blank- remove row

    That should remove most of my struggles, I just don't know how to write the script to complete it. I have added the file- please let me know if you need any additional details!

    I added the file that I manually cleaned up- KS OJR- 03202024


    Thank you in advance for any help on this,

    Adam
    Attached Files Attached Files
    Last edited by Newtonus_Prime; 03-20-2024 at 02:00 PM. Reason: Added clean file

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Hi Adam,

    You would have better responses if you could show us the expected results as well

  3. #3
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    I just added the file that I cleaned up to compare.

    Thank you,

    Adam

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

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Please Login or Register  to view this content.
    UPDATED code and file
    Attached Files Attached Files
    Last edited by JohnTopley; 03-20-2024 at 06:23 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Hi John,

    I was attempting to run this and I didn't see anything happen. I may be doing something wrong, but I'm not sure. I opened the VBA editor and ran module 1. Any help would be appreciated!

    Thank you in advance,
    Adam

  6. #6
    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,205

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    If you did not realise, I copied the raw data from "KS OJR 03202024" into sheet "Table 1" of "KS OJR 03202024 TEST" rather have the data in separate file.

    Click "RUN" button on sheet "KS OSJ" (wrong name!)

  7. #7
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Oh my. I was on the wrong page. Thank you! That worked great. I do have one other question. Once the script cleans this sheet, I have been formatting column D "Ship" to mm/dd/yyyy and for some reason the format doesn't change until I manually double click in each cell. Is there a way to automate that into this script?

    Thank you,

    Adam

  8. #8
    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,205

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JohnTopley; 03-21-2024 at 09:27 AM.

  9. #9
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    One more question. Can I just paste my exported file into Table 1 and hit run on the KS OSJ tab? Do I need to delete the current data that is in KS OSJ in order to run it? Sorry, VBA is not my strong suit and every book that I have read is more confusing than the previous one.

    Thank you,
    Adam

  10. #10
    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,205

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Yes, but CLEAR ("ClearContents") "Table 1" to avoid leaving extraneous data as the new data might be a smaller range than the new replacement.

    Then just "RUN".

  11. #11
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Is there a reason why the script is only returning 71 lines? It should be returning a lot more lines.

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

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    I updated the macro (post #8) to ensure it activated the correct sheet.

    Please Login or Register  to view this content.

  13. #13
    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,205

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Updated file
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Thank you JohnTopley! You are a lifesaver. I have been manually converting this for about a month and can't imagine how much time this will save me.

    Thanks again,

    Adam

  15. #15
    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,205

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    You're very welcome and thank for the rep.

    Come back to the forum if you ever need help in the future: there is always someone willing and able to assist you.
    Last edited by JohnTopley; 03-21-2024 at 10:35 AM.

  16. #16
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    You could do it with Power Query too. PQ is a native tool of Excel.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Hi DJunqueira,

    Would I just clear contents on Table 1 and paste my data in there to make this work? I dont want to mess anything up, but definitely appreciate an alternate method!

    Thank you,

    Adam

  18. #18
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    I do have one final question. Is it possible to keep the display on the tab where the results are once you click the "RUN" button? It jumps over to the Table 1 tab after you click the button as of now.

  19. #19
    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,205

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Apologies: I thought I had posted file with the above requirement.
    Attached Files Attached Files

  20. #20
    Forum Contributor
    Join Date
    05-11-2020
    Location
    Kansas City
    MS-Off Ver
    Office 365
    Posts
    162

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Perfect. Thanks again!

  21. #21
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Need help removing "bad" data from Excel File that is exported from a PDF daily

    Yes, you can place there as many as new data as you want.

+ 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: 7
    Last Post: 12-03-2022, 01:31 PM
  2. Unable to "Open" an exported excel (97-2003) during run time in Macros (Excel - 2010)
    By vmanoharan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2018, 05:53 AM
  3. [SOLVED] VBA to export from Access to Excel and wright in field "Exported"
    By SGT in forum Access Tables & Databases
    Replies: 9
    Last Post: 02-05-2015, 09:41 AM
  4. [SOLVED] removing "enter" from a downloaded file in a text cell
    By Fletch74 in forum Excel General
    Replies: 6
    Last Post: 11-25-2013, 05:14 AM
  5. [SOLVED] Removing ".", "?" or "!" from last word of sentence and replacing it later in vba.
    By staggers47 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-16-2013, 07:20 AM
  6. Transfert cell values from file "A" to file "B" skipping columns in file "B".
    By Sentrosi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2009, 11:11 PM
  7. Removing "Save As" Command from an excel file.
    By Camper Joe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-19-2005, 11:10 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