My code so far:

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 2/7/2008 by Accounting
'
' Keyboard Shortcut: Ctrl+e
'
Dim wsData, wsIIF, wsInvoices As Worksheet
Dim intIFirstRow, intINextRow, intILastRow As Integer
Dim intDFirstRow, intDNextRow, intDLastRow As Integer
Dim intInvoiceCount As Integer
Dim lngInvoiceTot As Double

Set wsData = Sheets("AR-Lines")
Set wsIIF = Sheets("AR-Lines-QB")

lngInvoiceTot = 0
intIFirstRow = 4
intINextRow = 5

intDFirstRow = 2
intDNextRow = intDFirstRow

Do
    Do

        If IsNumeric(wsData.Cells(intDNextRow, "ad")) Then
            lngInvoiceTot = lngInvoiceTot + wsData.Cells(intDNextRow, "ad").Value
            wsIIF.Cells(intINextRow, "a") = "SPL"
            wsIIF.Cells(intINextRow, "b") = "INVOICE"
            wsIIF.Cells(intINextRow, "c") = wsData.Cells(intDNextRow, "j")
            wsIIF.Cells(intINextRow, "d") = "=VLOOKUP(" & """" & wsData.Cells(intDNextRow, "f") & """" & ",'C:\Documents and Settings\accounting.TMI\My Documents\AR\[PRODUCTS.xls]PRODUCTS'!$C$1:$D$560,2)"
            wsIIF.Cells(intINextRow, "f") = wsData.Cells(intDNextRow, "ad")
            wsIIF.Cells(intINextRow, "f") = wsIIF.Cells(intINextRow, "f") * -1
            wsIIF.Cells(intINextRow, "h") = "=VLOOKUP(" & """" & wsData.Cells(intDNextRow, "f") & """" & ",'C:\Documents and Settings\accounting.TMI\My Documents\AR\[PRODUCTS.xls]PRODUCTS'!$C$1:$e$560,3)"
            wsIIF.Cells(intINextRow, "i") = wsData.Cells(intDNextRow, "g")
            wsIIF.Cells(intINextRow, "j") = "N"
            wsIIF.Cells(intINextRow, "k") = "N"
            intINextRow = intINextRow + 1
        End If

        intDNextRow = intDNextRow + 1
    Loop Until wsData.Cells(intDFirstRow, "a") <> wsData.Cells(intDNextRow, "a")

    wsIIF.Cells(intINextRow, "a") = "ENDTRNS"

    wsIIF.Cells(intIFirstRow, "a") = "TRNS"
    wsIIF.Cells(intIFirstRow, "b") = "INVOICE"
    wsIIF.Cells(intIFirstRow, "c") = wsData.Cells(intDFirstRow, "j")
    wsIIF.Cells(intIFirstRow, "d") = "A/R Accounts Receivable"
    wsIIF.Cells(intIFirstRow, "e") = "=VLOOKUP(" & """" & wsData.Cells(intDFirstRow, "c") & """" & ",'C:\Documents and Settings\accounting.TMI\My Documents\AR\[CV.xls]CV'!$A$1:$B$416,2)"
    wsIIF.Cells(intIFirstRow, "f") = lngInvoiceTot
    wsIIF.Cells(intIFirstRow, "g") = "=RIGHT(" & """" & wsData.Cells(intDFirstRow, "a") & """" & ",5)"
    wsIIF.Cells(intIFirstRow, "j") = "N"
    wsIIF.Cells(intIFirstRow, "k") = "N"
    
    intIFirstRow = intINextRow + 1
    lngInvoiceTot = 0
    intINextRow = intINextRow + 2
    intDFirstRow = intDNextRow

Loop Until wsData.Cells(intDNextRow, "a") = ""

End Sub

I have the following sheets:

1. AR-Lines
This sheet contains the data I’m using to create a file in IIF format.

2. AR-Lines-QB
This sheet contains the data the above code formats into data lines that is imported into QuickBooks.

I will be receiving text files on a continuous basis. These text files, which will be the first sheet, AR-Lines, will contain invoice lines. Within the AR-Lines, there will be multiple lines which belong to the same invoice. There will be invoices that are repeated from file to file. I do not want to have the same invoices to be processed to the second sheet, AR-Lines-QB.

Therefore, I’ve created a third sheet, InvoiceNumbers. This will be a list of invoice numbers that have already been processed. When I run the macro to create the input file for QuickBooks, I want to be able to determine if the invoice numbers in the current text file, which will be loaded into AR-Lines, is in the sheet InvoiceNumbers. If it is there, then I want to bypass those lines. If it isn’t there, then I want to add the invoice number to InvoiceNumbers.