Hello - I've worked up a VBA routine that runs from Access 2003 to search a Excel 2003 xls cell by cell, using the code below.
It is called by a routine that searches a set of nested folders recoursively, looking for files with a particular string in the file name.
It works fine in the first workbook it finds, but when it runs through the next workbook, it blows up with:
1004 - Method 'Rows' of object '_Global' failed
on the line below:
LastRow = .Range("A" & Rows.count).End(xlUp).Row
I believe I am closing all the Excel obj var's properly (also below), but I must not be?
When I look at Task Manager after it blows up, I see two "EXCEL.EXE"'s running in the Process tab.
What am I doing wrong?
For Each wks In wbk.Worksheets
LastRow = .Range("A" & Rows.count).End(xlUp).Row '-- <<< blows up here 2nd time thru
LastCol = .UsedRange.Columns.count
For intRows = 1 To wks.UsedRange.Rows.count
For intCols = 1 To wks.UsedRange.Columns.count
Next '-- Col
Next '-- row
Next '-- wks
'-- at the end of each workbook
Set wks = Nothing
Set wbk = Nothing
Set app = Nothing