troubleshooting Question

what should be the best correct option to use SpecialCells(xlCellTypeLastCell) or Find * or rows.count?

Avatar of Flora Edwards
Flora EdwardsFlag for Sweden asked on
VBAMicrosoft ExcelMicrosoft Office
2 Comments1 Solution159 ViewsLast Modified:
I am new with in this VBA world.

still learning.

i am confused a bit with the different methods used to find the last row or last column of a specific sheet.

which one should i use?  what is the pros and cons of each of the below methods?
which one of them is more robust so that it will not miss anything?

'Using Find Function
  LastRow = sht.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row

'Using SpecialCells Function
  LastRow = sht.Cells.SpecialCells(xlCellTypeLastCell).Row

'Ctrl + Shift + End
  LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros