+ Reply to Thread
Results 1 to 2 of 2

Thread: Macro to insert row & formulas and format, but no other data.

  1. #1
    Registered User
    Join Date
    09-16-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    14

    Macro to insert row & formulas and format, but no other data.

    I dont know much about macros myself or how to write them.

    I basically want to be able to highlight X amount of cells (100 for example), then click a macro button that will copy the formulas and formatting from the row directly above them.

    I found this.. however it doesn't quite copy the formatting properly. It copies the colour but not the border on all cells.

    Sub InsertRowFormulas()
    Application.ScreenUpdating = False
    Dim cell As Range
    Selection.EntireRow.Insert
    For Each cell In Intersect(ActiveSheet.UsedRange, Selection.Offset(-1, 0).EntireRow)
    If cell.HasFormula Then
    cell.Copy cell.Offset(1, 0)
    End If
    Next
    Application.ScreenUpdating = True
    End Sub

    Any ideas on how to fix this??? It copies the formulas as wanted.

  2. #2
    Forum Guru pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,150

    Re: Macro to insert row & formulas and format, but no other data.

    gonzalraf
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    VBA for smarties - snb

+ 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.2.0