View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Mysore Mysore is offline
external usenet poster
 
Posts: 5
Default macros to insert specific rows without altering the formula

Hi Kassie,

Many thanks for your help. It worked. However the new rows did not copy the
formula from the above row. Is it possible to make the rows automatically
copy the formulas from the previous row. Additionally, I want to delete the
extra rows created, is it possible to get a code for that too.
Appreciate your help again.

Thanks


"kassie" wrote:

Hi

When you insert rows between the 1st and last row, the formula will
automatically adjust. If you insert a row before the first row, or after the
last row, you will have to adjust the formula.

Do you always want to insert rows in the same area, or do you want to select
an area, and then have the rows inserted there? Assuming the latter, you can
use something like the following:

Dim iInsert As Integer

Sub AddRows()
iInsert = Range("E1").Value
If iInsert < 1 Then
Exit Sub
Else
For iInsert = iInsert To 1 Step -1
Selection.EntireRow.Insert
Next
End If
End Sub

Of course, change E1 to whatever your reference cell is.

You can also use an input box to obtain the number of rows to be inserted.
That would in my opinion work better, since you then do not have to go to eg
Row 1 to insert your criteria, and then back down to row 500 before running
the macro?

--
Hth

Kassie Kasselman
Change xxx to hotmail


"Mysore" wrote:

I have got a table with data in rows and a formuls in the last row of the
table .
I need a macro which will looks up a reference cell which contains the no
of rows
to be inserted and then inserts the rows accordingly . Also the row
containing the
formula must include all the data including the newly added rows.

Appreciate an urgent feedback.

Krishna