+ Reply to Thread
Results 1 to 3 of 3

Thread: adding row in a worksheet

  1. #1
    Registered User
    Join Date
    01-21-2012
    Location
    united States
    MS-Off Ver
    Excel 2010
    Posts
    15

    adding row in a worksheet

    How can I add a row to a work sheet when I reach the last row in my worksheet? The row has many steps and formulas in it.
    I would like to have a new row added when ever a new (reqistration number) col a1 is added.
    Last edited by Genebu; 02-01-2012 at 11:25 AM. Reason: solved

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

    Re: adding row in a worksheet

    Hi Genebu

    you can modify this worksheet event code to suit

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim TargetCell As Range, N As Long
        On Error GoTo FormulaFillFail
        If (Not IsNumeric(Target.Value)) Or IsEmpty(Target) Then
            Exit Sub
        End If
        For Each TargetCell In Intersect(ActiveSheet.UsedRange, Target.EntireRow)
            If TargetCell.Value = "" Then
                For N = 1 To TargetCell.Row - 1
                    If TargetCell.Offset(-N, 0).HasFormula Then
                        TargetCell.Offset(-N, 0).Copy Destination:=TargetCell.Offset(-N + 1, 0).Resize(N, 1)
                        Exit For
                    End If
                Next N
            End If
        Next TargetCell
        Exit Sub
    FormulaFillFail:
    End Sub
    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

  3. #3
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: adding row in a worksheet

    Look at Formatting as a Table
    Last edited by royUK; 01-28-2012 at 05:27 AM.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

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