code help please

S

sevelingard

i am trying to create a simple macro whereby i add in a new person to a
holiday chart which involves adding in some formula lines and so on, but how
do i make sure my macros start copy pasting at the next available line ?
 
G

Gary''s Student

The following returns the first row that is completely empty. May not be at
the end of your data:

Sub FirstEmptyRow()
Dim j As Long
Dim i As Long
Dim rr As Range

Set rr = ActiveSheet.UsedRange

j = rr.Rows.Count + rr.Row
If j > 65536 Then
Exit Sub
End If

For i = 1 To j
If Application.CountA(Rows(i)) = 0 Then
Cells(i, 1).Select
Exit Sub
End If
Next i
End Sub
 
Top