Thread: End property
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default End property

If you put
=counta(a:a)
in an empty cell, what's returned?



Stefi wrote:

Thanks guys to all of you, it's nice, but the my problem remains:

Range("A" & Rows.Count).End(xlUp).Row

ALWAYS gives 1. I'd like a formula giving 1 when I have only header row, 2
when header row and one data row, etc.
I found that
Columns("A:A").Find(What:="*", _
After:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlValues, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row

works this way, but I thought that I can get the same result with the End
property in a simpler way. Was I wrong?

Regards,
Stefi

€˛Bob Phillips€¯ ezt Ć*rta:

LastRow = Range("A" & Rows.Count).End(xlUp).Row


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Stefi" wrote in message
...
Hi All,

I wanted to use
Columns("A:A").End(xlDown).Row
to determine last cell in column A. Column A has a header in A1.
Columns("A:A").End(xlDown).Row gives the correct result if I have at least
one not blank cell (A2) in column A, but gives 65536 if I have only the
header. I'd expect 1 as result.

Is there a simple way of getting 1 in this case, other then complicated IF
structures?

Thanks,
Stefi





--

Dave Peterson