View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Question about "End(xlUp)" property

Terence,

Test the Value of the cell and move down only if it is not empty.
E.g.,

Dim Rng As Range
Set Rng = Cells(Rows.Count, "A").End(xlUp)
If Rng.Value < "" Then
Set Rng = Rng(2, 1)
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Terence" wrote in message
...
Hi,

I am writing some codes to find out the last non-empty
cell in column A of my worksheet by using the code "Range
("A65536").End(xlUp).Row", then I can write something new
at the next row.
However, if the cell (A1) at row 1 is empty, it doesn't
return 0 but 1. If I write something at the next row, then
it is written to row 2 (cell A2) but leaving cell A1
empty. How should I avoid this problem? Is there any
better coding method?
Thanks a lot in advance!!

Terence