selecting next empty cell
I am trying to understand what you want to do. Let's see if I have it right:
You want to copy data from the preceding row (Columns A through ?) to the
next empty row and you are using column A as your control column because it
will not have blank cells between the starting row and the last row. Do I
have the picture correct?
"ASU" wrote:
Thank you both very much for getting back so quick. The things is I'm using
the code below to copy and paste formulas to the next row. This I do manually
by selecting the next empty cell in column "A". What I'm trying to do is for
the code to activate when ever data is entered in the last row, so that the
formulas are pasted to the next empty row. I hope that wasn't too borring!!!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lastrow As Long
If Target.Column < 1 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Not IsEmpty(Target) Then Exit Sub 'cell must be empty
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
If Target.Row < lastrow + 1 Then Exit Sub 'Row must be empty
Rows(Target.Row - 1).Copy
ActiveSheet.Paste
Application.CutCopyMode = False
On Error Resume Next
Target.EntireRow.SpecialCells(xlConstants).ClearCo ntents
Application.EnableEvents = False 'should be part of change macro
Target.Select
Application.EnableEvents = True 'should be part of change macro
End Sub
--
ASU
"kassie" wrote:
If you inserted the data, press Enter. If it is done by a macro (the data
insertion), then you do not need to select the next empty cell to work with
it. You can use Offset(1, 0) to work with the next cell though
"ASU" wrote:
How do I automatically select the next empty cell, in column "A", when data
has been inserted.
--
ASU
|