+ Reply to Thread
Results 1 to 3 of 3

inserting row using macro

Hybrid View

  1. #1
    Registered User
    Join Date
    03-11-2009
    Location
    Seattle, WA
    MS-Off Ver
    Office 2007
    Posts
    58

    inserting row using macro

    Hi I"m toally new to Macros...I'm trying to record a macro to insert rows using the following, but it's not copying the formulas in some cells...
    I've added a radio button and assigned the macro, but it seems to add a blank row without filling down with the formulas from the cells above. Can anyone help with what I need to change to make sure the inset row picks up formulas from row above?
    Range: A to Y
    I'm trying to get the macro to add rows above the "radio button" i created on the last cell. The formulas in some cells pickup data entered in other worksheets within the same workbook.

    I'm using:

    Sub InsertRow()
    Activecell.EntireRow.Insert
    Activecell.Offset(0,0).Value=""
    End Sub
    Looking forward to any help!

    Thanks,
    Last edited by Dannypak; 03-18-2009 at 02:10 PM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: inserting row using macro

    Try with this code:
    Sub InsertRow()
       ActiveCell.EntireRow.Insert
       ActiveCell.Offset(0, 0).Value = ""
       On Error Resume Next
       For Each f In ActiveCell.Offset(-1, 0).EntireRow.SpecialCells(xlCellTypeFormulas)
          f.Copy f.Offset(1, 0)
       Next
       On Error GoTo 0
    End Sub
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    03-11-2009
    Location
    Seattle, WA
    MS-Off Ver
    Office 2007
    Posts
    58

    Re: inserting row using macro

    That worked great!
    one little problem it runs into is:
    when the cursor is not at the "Insert Row" radio button, it inserts rows, but copies the formula from above rather than filling down:

    i.e. =sum(a3+1), then next cell should read =sum(a4+1) but it copies the same =sum(a3+1).

    Any way to fix? how about to add 5 new rows rather than just one?

    Thanks again!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1