The iteration is there just in case there is an empty row embedded somewhere
in UsedRange. If there are no internal empties, then:
j = rr.Rows.Count + rr.Row
will go one row past UsedRange and insure finding something (I hope)
--
Gary's Student
"Jim Thomlinson" wrote:
This is another way to get the last row. It is a bit faster as it does not
iterate one cell at a time.
Dim lngLastRow As Long
with sheets("Sheet1")
On Error Resume Next
.select
lngLastRow = .Cells.Find(What:="*", _
After:=wks.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On error Goto 0
.cells(lnglastrow + 1, "A").select
end with
--
HTH...
Jim Thomlinson
"Gary''s Student" wrote:
Try this. It will select the first cell in the first row that is totally
empty:
Sub Macro1()
Dim j As Long
Dim i As Long
Dim r, rr As Range
Set rr = ActiveSheet.UsedRange
j = rr.Rows.Count + rr.Row
For i = 1 To j
If Application.CountA(Rows(i)) = 0 Then
Cells(i, 1).Select
Exit Sub
End If
Next i
End Sub
--
Gary''s Student
"Sheldon" wrote:
That's great help Jim. How can I get this to look at columns A-Q?
"Jim Thomlinson" wrote:
With Sheets("Sheet1")
.select
.cells(rows.count, "A").end(xlup).offset(1,0).select
end with
This will select the first blank row looking at the items in column A...
--
HTH...
Jim Thomlinson
"Sheldon" wrote:
I'm writing a Macro that copies information from several worksheets to one
worksheet and I need the next block of data to be pasted in the first row
that is empty. Can someone help me with some VB code that will select a cell
in the first empty row?
Thanks for any assistance.