Well I built this sweet vba code to take a notepad file.. format,extract data, then do analysis. Works perfect.
What I was told that this 1 file was 1 invoice therefore 1 report.
Well actually the file may contain many invoices.
I can search and find the Page 1 which starts the new invoice, but do I need to start over ( to reduce headaches ), or try to add something to the code to add the invoice # to the extracted data?
Here is the code:
Sub E_Extract()
x = 1
y = 2
Sheets("charge report").Select
'Find Last Row in Column A
lr = Sheets("charge report").Cells(Rows.Count, "A").End(xlUp).Row
'Extracts Product Code / Description / Lot# / Charge Code
Do Until x > lr
Do Until Left(Sheets("charge report").Cells(x, 11), 1) = "Q" Or x > lr
x = x + 1
Loop
Row = x
pcode = (Sheets("charge report").Cells(x, 3))
desc = (Sheets("charge report").Cells(x, 4))
lot# = (Sheets("charge report").Cells(x + 1, 9))
chcode = (Sheets("charge report").Cells(x, 11))
'Paste Extracted Data in "Data" Sheet
Sheets("data").Cells(y, 1) = Row
Sheets("data").Cells(y, 2) = pcode
Sheets("data").Cells(y, 3) = desc
Sheets("data").Cells(y, 4) = lot#
Sheets("data").Cells(y, 5) = chcode
x = x + 1
y = y + 1
Loop
End Sub
What I was told that this 1 file was 1 invoice therefore 1 report.
Well actually the file may contain many invoices.
I can search and find the Page 1 which starts the new invoice, but do I need to start over ( to reduce headaches ), or try to add something to the code to add the invoice # to the extracted data?
Here is the code:
Sub E_Extract()
x = 1
y = 2
Sheets("charge report").Select
'Find Last Row in Column A
lr = Sheets("charge report").Cells(Rows.Count, "A").End(xlUp).Row
'Extracts Product Code / Description / Lot# / Charge Code
Do Until x > lr
Do Until Left(Sheets("charge report").Cells(x, 11), 1) = "Q" Or x > lr
x = x + 1
Loop
Row = x
pcode = (Sheets("charge report").Cells(x, 3))
desc = (Sheets("charge report").Cells(x, 4))
lot# = (Sheets("charge report").Cells(x + 1, 9))
chcode = (Sheets("charge report").Cells(x, 11))
'Paste Extracted Data in "Data" Sheet
Sheets("data").Cells(y, 1) = Row
Sheets("data").Cells(y, 2) = pcode
Sheets("data").Cells(y, 3) = desc
Sheets("data").Cells(y, 4) = lot#
Sheets("data").Cells(y, 5) = chcode
x = x + 1
y = y + 1
Loop
End Sub