Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with finding last cell

Status
Not open for further replies.

pedro404

Programmer
Feb 17, 2004
11
DE
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top