+ Reply to Thread
Results 1 to 12 of 12

Insert rows with copying formula from above row

Hybrid View

  1. #1
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Insert rows with copying formula from above row

    Hello masta-s,

    And to make me happy for the rest of my life
    To make the Forum Moderators happy, and before you can expect a reply to your problem, you will have to read and follow the Forum Rules. > Wrapping your Code <, for instance.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  2. #2
    Registered User
    Join Date
    10-05-2012
    Location
    Kazakhstan
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Insert rows with copying formula from above row

    Quote Originally Posted by Winon View Post
    Hello masta-s,



    To make the Forum Moderators happy, and before you can expect a reply to your problem, you will have to read and follow the Forum Rules. > Wrapping your Code <, for instance.
    Winnon, thanks for help, hope this will work now :-)

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Insert rows with copying formula from above row

    Hi masta-s,

    Merging Cells causes a myrid of problems. Would it be o.k. with you if we did not Merge any Cells?

  4. #4
    Registered User
    Join Date
    10-05-2012
    Location
    Kazakhstan
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Insert rows with copying formula from above row

    Quote Originally Posted by Winon View Post
    Hi masta-s,

    Merging Cells causes a myrid of problems. Would it be o.k. with you if we did not Merge any Cells?
    Winon,

    Sure it will work. I just have an excel sheet where they've managed to apply that, but unfortunately it's password protected as well as VBA code is pw protected too. But it looks so nice...

    Anyway, if there's a lot to do to make this work then sure at least pasting the rows without merging will do. Thanks in advance!

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Insert rows with copying formula from above row

    Hi, masta-s,

    maybe try these two modified versions of your macros:
    Sub Macro1()
    '
    ' Macro1 Macro
    '
    ' Keyboard Shortcut: Ctrl+i
    '
    If Selection.Cells(1).Row < 13 Then Exit Sub
     Rows(Selection.Cells(1).Row).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("G" & Selection.Cells(1).Row - 1).AutoFill Destination:=Range("G" & Selection.Cells(1).Row - 1 & ":G" & Selection.Cells(1).Row), Type:=xlFillDefault
    End Sub
    I went from A to J on this, we could use an array to hold all Columns
    Sub Macro2()
    '
    ' Macro2 Macro
    '
    ' Keyboard Shortcut: Ctrl+s
    '
        Dim lngCol As Long
        
        Rows(ActiveCell.Row).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        For lngCol = 1 To 10
          With Range(Cells(ActiveCell.Row, lngCol), Cells(ActiveCell.Row + 1))
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlBottom
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
            .Merge
          End With
        Next lngCol
        With Range("M71:M72")
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlBottom
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
            .Merge
        End With
    End Sub
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

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