View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Macro for Inserting Rows

ActiveCell.EntireRow.Insert Shift:=xlDown
ActiveCell.Offset(1, 0).EntireRow.Copy Cells(ActiveCell.Row, 1)


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Dickie Worton" <Dickie wrote in message
...
Hi, I have never posted before but hope that someone can help me with a
problem now that I have.

I am developing a spreadsheet in which I want to give users the power to
insert additional rows, which sounds easy enough. However what I want is
to
do is have a macro they can use to do this, as for every row that is
inserted
I need the formulas present in the existing rows to be copied into newly
inserted row. I don't think the users will have the awareness to copy the
formulas into the new rows themselves, hence I want to make it happen
automatically.

I found some VB script in another posting that has almost solved this for
me
(below), but the problem is that running this inserts a row in the same
row
position each time (row 18). What I want is for the user to either
highlight
the row of their choosing or click into a cell in that row and for the
macro
to insert a row in the position they have selected.

Can anyone suggest what I am doing wrong, please? I am a novice with VB
script so don't know where to start.

Rows("18:18").Select
Selection.Insert Shift:=xlDown
Range("H15").Select
INSERTPT = ActiveCell.Value
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Range("H18").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False