Results 1 to 3 of 3

Insert rows and copy formula

Threaded View

  1. #1
    Registered User
    Join Date
    03-26-2013
    Location
    Bucharest
    MS-Off Ver
    Excel 2010
    Posts
    18

    Insert rows and copy formula

    Hi all,

    I have the code below for inserting a certain no of rows and copy the formula. From the selected cell it inserts and copy the upper row

    What I would like to do and can't by myself due to my limited knowledge about VBA:
    1. To automatically run the macro only if in column A I have "yes"
    2. To copy the selected row (the one where is "yes" in column A) and to insert rows below it.
    3. To replace all "yes" findings in column A with "no"

    Thank you all for your help!

    Sub InsertRow()
        Dim Rng, n As Long, k As Long
        Application.ScreenUpdating = False
        Rng = InputBox("Enter number of rows required.")
        If Rng = "" Then Exit Sub
        Range(ActiveCell, ActiveCell.Offset(Val(Rng) - 1, 0)).EntireRow.Insert
        k = ActiveCell.Offset(-1, 0).Row
        n = Cells(k, 256).End(xlToLeft).Column
        Range(Cells(k, 1), Cells(k + Val(Rng), n)).FillDown
    End Sub
    Last edited by costin; 07-05-2013 at 09:40 AM.

Thread Information

Users Browsing this Thread

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

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