u/NotMatt - 6 Archived Voat Posts in v/programming
u/NotMatt
  • home
  • search

u/NotMatt

0 posts · 6 comments · 6 total

Active in: v/programming (6)

  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››
Comment on: Need help with querying a table.

Happy to! Let me know if there is anything else I can help with :)

0 12 Aug 2015 22:07 u/NotMatt in v/programming
Comment on: Need help with querying a table.

Yeah, as I said PDF is a clusterfuck for parsing. Keep trying to find a converter that works is all I can suggest. If there are only a few rows with incomplete data it might honestly be easier to manually repair those rows.

0 12 Aug 2015 22:02 u/NotMatt in v/programming
Comment on: Need help with querying a table.

Yay! Can you verify that it deleted the correct rows? The ones that are left should NOT have empty cells in the "mensagem" column.

The next step would be to copy the data into one master sheet, and run Excels "sort" function (found under the Data" tab) if necessary. That should really be it. Is there anything else you wanted to do with the data?

0 12 Aug 2015 21:24 u/NotMatt in v/programming
Comment on: Need help with querying a table.

I edited my earlier post, please check it or some code snippets. I have yet to find a storage/backup site that isn't blocked, so I don't think I'm going to actually be able to look at the spreadsheet.

EDIT: I have gone back and commented the modified code. In VBA a ' denotes a comment, so all text appearing after the ' character is a comment. Modify the code as necessary to fit the spreadsheet, as I am unable to view it.

0 12 Aug 2015 21:14 u/NotMatt in v/programming
Comment on: Need help with querying a table.

Oof! That's basically a brick wall. Parsing a PDF is awful at best. I found this with Google, but can't test it because it is blocked on our network. Check it out: www.zamzar.com/convert/pdf-to-xls/

If we can get it into a spreadsheet we can easily use VBA to remove the unwanted rows.

EDIT:

Some code I shamelessly stole from the MrExcel forums:

Sub DeleteRowWithContents()
'========================================================================
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D
'========================================================================
    Last = Cells(Rows.Count, "D").End(xlUp).Row
    For i = Last To 1 Step -1
        If (Cells(i, "D").Value) = "Record Only" Then
    'Cells(i, "A").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW
            Cells(i, "A").EntireRow.Delete
        End If
    Next i
End Sub

Source

We can modify this to remove all rows that contain empty cells in column P, skipping the first as I assume there will be a header row.

Sub DeleteRow()
'========================================================================
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH EMPTY CELLS IN COLUMN P
'========================================================================
    Last = Cells(Rows.Count, "P").End(xlUp).Row 'Get the last row number in spreadsheet
    For i = Last To 1 Step -1 'Loop N times (Last row number to 1. Not inclusive, so row 2 to N)
        If IsEmpty(Cells(i, "P").Value) Then 'If cell in column P on current row is empty
            Cells(i, "A").EntireRow.Delete 'Delete entire row
        End If
    Next i 'Loop
End Sub

This code can be injected as a macro by pressing Alt+F11 to open the VBA editor. Copy and paste the above modified code into the "This Workbook" module in project explorer on the left hand side of the window. Save the workbook, and then run the macro from the developer toolbar.

File > Options > Customize Ribbon > Tick the box next to "Developer".

Open the "Developer" tab and click "Macros", then select the "DeleteRow" Macro and click "Run".

1 12 Aug 2015 20:54 u/NotMatt in v/programming
Comment on: Need help with querying a table.

Hey! I'm bored at work and would up to helping. The link you posted doesn't work though. Is the table a table in a database, or excel spreadsheet? Or is it just an HTML table?

3 12 Aug 2015 20:36 u/NotMatt in v/programming
  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››

archive has 9,592 posts and 65,719 comments. source code.