Eric,
Try the code below. Assumes that last names are in column B, first names in A.
HTH,
Bernie
MS Excel MVP
Sub InsertBlockAboveOrBelow()
Dim myCell As Range
Dim newFName As String
Dim newLName As String
newFName = InputBox("What is the new first name?")
newLName = InputBox("What is the new last name?")
If Cells(ActiveCell.Row, 1).Value = "" Then
Set myCell = Cells(ActiveCell.Row, 1).End(xlUp)
Else
Set myCell = Cells(ActiveCell.Row, 1)
End If
With myCell.Resize(4).EntireRow
If MsgBox("Above = ""Yes"", Below = ""No""", vbYesNo) = vbYes Then
.Copy
.Insert
myCell.Offset(-4).Value = newFName
myCell.Offset(-4,1).Value = newLName
Else
.Copy
.Offset(4).Insert
myCell.Offset(4).Value = newName
myCell.Offset(4,1).Value = newLName
End If
End With
Application.CutCopyMode = False
End Sub
"Arnold" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All,
> In a scheduling worksheet, first and last names are listed in the left
> columns, formulas in columns to the right of the names, and then
> individual days are added daily in columns to the right of the
> formulas. Marks are made in the intersections of days and people.
>
> I would like to have a cmd button or menu to add new people. The
> tricky part is that 1 person's info occupies 4 consecutive rows. Each
> row contains different formulas that would have to be included in the
> copy. It would be best if users could click on any 1 of the 4 rows of
> an existing person's record, and then click the cmd to add a new
> person's record (4 new rows) either above or below the existing
> person's record. Code would have to recognize where one group of rows
> starts and ends.
>
> Note that each person's name is put on the top row (cols A and B) of
> his or her record, so the presence of text 0 or 1 or 2 or 3 lines
> above where the cursor is could be the identifying feature that could
> maybe make this happen. I just don't know how. Any help would be
> greatly appreciated.
>
> Thanks,
> Eric
>
|