> The only thing that works is to clean the workbook and start with no rows.
> New rows added from text files and marked with "x"es are processed
> correctly.
> Does anyone have an idea what could be the cause of this strange behavior?
> Any help would be appreciated.
Hi Jan Karel,
This is a snippet of the code that checks for an "x" in column one, the
colun that has "Processed" as column header.
Dim oExcel As Excel.Application
Dim oArchiveExcelWorkBook As Excel.Workbook
Dim oCommonExcelWorkbook As Excel.Workbook
Dim oCurrentSheet As Excel.Worksheet
Dim oCurrentArchiveSheet As Excel.Worksheet
Dim oTemplSheet As Excel.Worksheet
Dim oFSO As Scripting.FileSystemObject
Dim tsExtractFile As Scripting.TextStream
Dim sLogFile As String
Dim sLogMsg As String
Dim vTargetRow As Variant
Dim lnTargetRow As Long
Dim lnRowIndex As Long
Dim sTargetRow As String
Dim lnColumnCount As Long
Dim lnMaxRows As Long
Dim lnMaxSheets As Long
Dim lnArchiveMaxRows As Long
Dim lnSourceRow As Long
Dim lnLastSourceRow As Long
Dim lnColumnIndex As Long
Dim sRecord As String
For lnRowIndex = 1 To lnLastSourceRow
If (oCurrentSheet.Cells(lnRowIndex, 1) = "Processed") Then
Else
If ((oCurrentSheet.Cells(lnRowIndex, 1) = "x") _
Or (oCurrentSheet.Cells(lnRowIndex, 1) = "X")) Then
lnSourceRow = lnRowIndex
lnTargetRow = lnTargetRow + 1
sTargetRow = Trim(Str(lnTargetRow))
' --- Copy and paste a row from the current Excel book and paste
it --------
' --- into the archive
--------
oCurrentSheet.Activate ''' No need to activate if explicit
qualifier is used?
oCurrentSheet.Range(Cells(lnSourceRow, 1), Cells(lnSourceRow,
lnColumnCount + 1)).Copy
oCurrentArchiveSheet.Activate
' Start with column B, to allow for the new date column in the
archive sheet.
oCurrentArchiveSheet.Range("B" & sTargetRow).Select
oCurrentArchiveSheet.Range("B" & sTargetRow).Activate
oCurrentArchiveSheet.Paste
' Insert today's date in the first cell of target row.
oCurrentArchiveSheet.Cells(CLng(sTargetRow), 1).Value = CStr(Date)
sLogMsg = CStr(Now) & " | ProcessExtractFiles function | " _
& " Copied row " & Str(lnRowIndex) & " to archive sheet"
tsLogFile.WriteLine (sLogMsg)
oArchiveExcelWorkBook.Save
oCurrentSheet.Cells(lnRowIndex, 1) = "r"
End If
End If
Next lnRowIndex
Ragnar
Ragnar Midtskogen - 04 Mar 2008 01:34 GMT
Never mind, the weird problem was due to an entry error.
The "x"es were followed by one or more blanks, in spite of instructions to
not enter any blanks.
I have updated the code to ignore blanks, which is what I should have done
to begin with (:-)).
Ragnar
> Hi Jan Karel,
>
[quoted text clipped - 57 lines]
>
> Ragnar
Jan Karel Pieterse - 04 Mar 2008 08:45 GMT
Hi Ragnar,
> Never mind, the weird problem was due to an entry error.
> The "x"es were followed by one or more blanks, in spite of instructions to
> not enter any blanks.
> I have updated the code to ignore blanks, which is what I should have done
> to begin with (:-)).
Thanks for letting us know!
Regards,
Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com