VBA code to determine last row not working correctly

I have 8 excel files I run this macro against to set a number format. On 7 of the files it works perfect, on one 0f the files it does not work correct. When I step through the macro, the lrow variable says the excel file only has 2 rows, when in actuality it has 80. When I step through the macro with the other 7 files, the lrow variable is correct. Trying to figure out what is different in this one file that would mess up the last row calc.

Dim lrow As Long
    lrow = Cells(Cells.Rows.Count, "E").End(xlUp).Row
    Range("E3:Q" & lrow).NumberFormat = "#,##0"

thx experts...BobR
bobrossi56Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Rather try the following code to find the last row used on as sheet.
You are getting the incorrect lrow value maybe because col. E on that file has data in two rows only.

lrow = Cells.Find("*", SearchOrder:=xlByRows, LookIn:=xlValues, SearchDirection:=xlPrevious).Row

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
[ fanpages ]IT Services ConsultantCommented:
Also for your information:

"(Excel) speed-up a loop using dichotomic logic"
[ http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28203209.html ]

That references:

"(Excel) reliable way to find the last row with a value, supporting hidden and autofiltered not contiguous rows"
[ http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28187684.html ]
bobrossi56Author Commented:
Your code for last row worked, so I will use that from now on...thx
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome. Glad I could help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.