View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jim May Jim May is offline
external usenet poster
 
Posts: 430
Default Find first empty row

Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)Row

Here's how you read this statement,,,

Cells - With the cells on your worksheet
(Rows.Count, 1) - Visualize yourself clicking in the cell at row 65536
column 1 (or cell A65536)
..End(xlUp) Visualize yourself next pressing the End key and then the Up
Arrow << keyboard equivalents
The results of the above would cause your cursor to run up column A to the
first non-blank cell and stop on or in it.
..Offset(1, 0) - means move down 1 row, move 0 columns
..row - not sure I just do it.... LOL

HTH



"Ragnar Midtskogen" wrote in message
...
Hello,

I need to find the first empty row in a worksheet. The sheet is just used
to enter text in, has no formulas.
I have Googled this and I am somewhat confused, there appears to be many
definitions of what is empty and many ways to find the row.
I have found something that seems to work, but I don't quite understand
how it works

iRow = objCurrentSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)Row

First, it looks like it just looks at column 1.
It looks like it starts at the last row and moves the top of the range up
until it finds something in a cell, but I don't see how it determines when
a cell contains something.

I need to scan several columns, so even if this code works how would I
expand the area scanned?

I have something that scans entire rows, I could use that but would prefer
to limit the scan to the first n columns, in case someone happened to
enter something outside the matrix to be used.

Any help would be appreciated.

Ragnar