the following piece of code is incorporated into an app that automatically scans through a series of folders for new data, each time that it finds it it places it into a txt document where excel picks it up.
the problem is that it only works for the first sheet then it returns an error (Runtime error '1004' method 'Cells' of object'_failed.
can anyone tell me what is wrong?
thanks in advance
peadar
Dim lRow As Integer, lCol As Integer, fRow As Integer, fCol As Integer
lCol = 14
fRow = 0
For i = 1 To lCol
lRow = Range(Cells(600, i), Cells(600, i)).End(xlUp).Row
If lRow > fRow Then
fRow = lRow
fCol = i
End If
Next i
lastcell = Range(Cells(fRow, lCol), Cells(fRow, lCol)).Address
stcell = "A1"
excel_app.ActiveSheet.PageSetup.PrintArea = stcell & ":" & lastcell
the problem is that it only works for the first sheet then it returns an error (Runtime error '1004' method 'Cells' of object'_failed.
can anyone tell me what is wrong?
thanks in advance
peadar
Dim lRow As Integer, lCol As Integer, fRow As Integer, fCol As Integer
lCol = 14
fRow = 0
For i = 1 To lCol
lRow = Range(Cells(600, i), Cells(600, i)).End(xlUp).Row
If lRow > fRow Then
fRow = lRow
fCol = i
End If
Next i
lastcell = Range(Cells(fRow, lCol), Cells(fRow, lCol)).Address
stcell = "A1"
excel_app.ActiveSheet.PageSetup.PrintArea = stcell & ":" & lastcell