goss
Active Member
- Joined
- Feb 2, 2004
- Messages
- 372
Hi all,
Using Excel 2010.
I extracted data from .pdf to Excel using Able2Extract
Now I need to scrub the output a bit.
I see commonalities in the data for the start and stop of each set of data that I can key in on.
Once I find the start and stop points for each set of data I would like to fill all rows in-between the points and then discard anything that remains outside of these boundaries.
I have something wrong in my logic, way too many rows are deleted.
Does anyone else see the problem in my logic?
Using Excel 2010.
I extracted data from .pdf to Excel using Able2Extract
Now I need to scrub the output a bit.
I see commonalities in the data for the start and stop of each set of data that I can key in on.
Once I find the start and stop points for each set of data I would like to fill all rows in-between the points and then discard anything that remains outside of these boundaries.
I have something wrong in my logic, way too many rows are deleted.
Does anyone else see the problem in my logic?
Code:
Option Explicit
Sub GetLineSets()
'Purpose: Identify relevant line sets, delete all other rows
Dim wbBook As Workbook
Dim wsData As Worksheet
Dim strFormula As String
Dim lngRows As Long
Dim C As Range
Dim blnFlag As Boolean
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With
Set wbBook = ThisWorkbook
Set wsData = wbBook.Worksheets("Data")
blnFlag = False
lngRows = wsData.Range("A65536").End(xlUp).Row
strFormula = "=IF(AND(ISERROR(FIND(""INVOICE NUMBER"",F1)),ISERROR(FIND(""INVOICE TOTAL"",C1))),0,""INVOICE"")"
With wsData
.Range("A1").EntireColumn.Insert
.Range("A1:A" & lngRows).Formula = strFormula
For Each C In .Range("A1:A" & lngRows)
C.Value = C.Value
Next C
Do While lngRows >= 1
If blnFlag = False Then
If .Cells(lngRows, 1).Value = 0 Then
.Cells(lngRows, 1).EntireRow.Delete
End If
Else
If .Cells(lngRows, 1).Value = "Department" Then
blnFlag = True
Else
If .Cells(lngRows, 1).Value = 0 Then
.Cells(lngRows, 1).Value = "Department"
Else
.Cells(lngRows, 1).EntireRow.Delete
End If
End If
End If
lngRows = lngRows - 1 'Decrement counter
Loop
End With
'Tidy Up
Set wbBook = Nothing
Set wsData = Nothing
Set C = Nothing
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationAutomatic
End With
End Sub