+ Reply to Thread
Results 1 to 3 of 3

Add row in sheet with formulas and merge

  1. #1
    Registered User
    Join Date
    10-16-2013
    Location
    Deurne
    MS-Off Ver
    Excel 2010
    Posts
    3

    Add row in sheet with formulas and merge

    Hi

    I have the following problem

    We are building a shift transfersheet. This sheet is to keep track of changes during the building of our module. In a row are several formulas, several cells are merged.

    Underneath the row that need to be inserted is a table.

    So we want a button that automatically insert a row with the info of the row above, also we don't know how many lines we need to add. But it always need to be added from line 45. This is in the template that we build allready.

    The code I have sofar is:
    Sub Add_row()
    '
    ' Add_row Macro
    '

    '
    Rows("46:46").Select
    Selection.Insert Shift:=xlDown
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
    .LineStyle = xlContinuous
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .Weight = xlMedium
    End With
    Selection.Borders(xlEdgeTop).LineStyle = xlNone
    Selection.Borders(xlEdgeBottom).LineStyle = xlNone
    With Selection.Borders(xlEdgeRight)
    .LineStyle = xlContinuous
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .Weight = xlMedium
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("C45").Select
    Selection.AutoFill Destination:=Range("C45:C46"), Type:=xlFillDefault
    Range("C45:C46").Select
    Range("D45").Select
    Selection.AutoFill Destination:=Range("D45:D46"), Type:=xlFillDefault
    Range("D45:D46").Select
    Range("G46:K46").Select
    With Selection
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlBottom
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
    End With
    Selection.Merge
    With Selection
    .HorizontalAlignment = xlLeft
    .VerticalAlignment = xlBottom
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = True
    End With
    Rows("47:47").Select
    End Sub

    From line 47 it inserts the line at row 47 and stays at 47.
    I hope this is enough info, and that somebody can help me out. This is build with recording the macro

    Gr DupkeVFR

  2. #2
    Registered User
    Join Date
    10-16-2013
    Location
    Deurne
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Add row in sheet with formulas and merge

    Hi to all.

    Is there some one that can help me out on this problem???

    Thx in advance

  3. #3
    Registered User
    Join Date
    10-16-2013
    Location
    Deurne
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Add row in sheet with formulas and merge

    It is solved.
    this is the solution:
    Add_row Macro
    '
    ' Select last row = 2 rows above "DN description"
    lrow = Application.WorksheetFunction.Match("xx xxxxxxxx", Range("B1:B200"), 0) - 2

    ' Copy last row into new row
    Rows(lrow & ":" & lrow).Select
    Selection.Copy
    Rows(lrow + 1 & ":" & lrow + 1).Select
    Selection.Insert Shift:=xlDown
    Application.CutCopyMode = False

    ' Empty contents new created row
    Range("E" & lrow + 1 & ":L" & lrow + 1).Select
    Selection.ClearContents
    Range("B" & lrow + 1).Select
    Selection.ClearContents

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Merge the two formulas together?
    By Dougiebn in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-26-2013, 03:52 PM
  2. How to merge two different formulas
    By hirenhkansara in forum Excel General
    Replies: 2
    Last Post: 08-24-2012, 08:13 AM
  3. How to merge two different formulas
    By hirenhkansara in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-24-2012, 07:50 AM
  4. Excel 2007 : Merge two formulas together
    By colins in forum Excel General
    Replies: 3
    Last Post: 02-20-2010, 10:57 AM
  5. Merge two formulas
    By Zaeguzah in forum Excel General
    Replies: 3
    Last Post: 11-12-2009, 03:35 PM

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