+ Reply to Thread
Results 1 to 10 of 10

formula for inserting rows

Hybrid View

  1. #1
    Carol49
    Guest

    formula for inserting rows

    Need formula that will allow a number e.g. 5 to be placed in a cell, which
    t\will then insert 5 rows. Thanks

  2. #2
    Bob Phillips
    Guest

    Re: formula for inserting rows

    That needs VBA.

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
    With Target
    If IsNumeric(.Value) Then
    .Resize(.Value).EntireRow.Insert
    End If
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.




    --
    HTH

    Bob Phillips

    "Carol49" <[email protected]> wrote in message
    news:[email protected]...
    > Need formula that will allow a number e.g. 5 to be placed in a cell, which
    > t\will then insert 5 rows. Thanks




  3. #3
    Carol49
    Guest

    RE: formula for inserting rows



    "Carol49" wrote:

    > Need formula that will allow a number e.g. 5 to be placed in a cell, which
    > t\will then insert 5 rows. Thanks

    Formula is what I am looking for, but I am getting a syntax error in the line
    If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
    I have copied and pasted, should I be doing something else? Thanks

  4. #4
    Bob Phillips
    Guest

    Re: formula for inserting rows

    Have you inserted it in a worksheet code module as instructed?

    --
    HTH

    Bob Phillips

    "Carol49" <[email protected]> wrote in message
    news:[email protected]...
    >
    >
    > "Carol49" wrote:
    >
    > > Need formula that will allow a number e.g. 5 to be placed in a cell,

    which
    > > t\will then insert 5 rows. Thanks

    > Formula is what I am looking for, but I am getting a syntax error in the

    line
    > If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
    > I have copied and pasted, should I be doing something else? Thanks




  5. #5
    Carol49
    Guest

    Re: formula for inserting rows



    "Bob Phillips" wrote:

    > Have you inserted it in a worksheet code module as instructed?
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Carol49" <[email protected]> wrote in message
    > news:[email protected]...
    > >
    > >
    > > "Carol49" wrote:
    > >
    > > > Need formula that will allow a number e.g. 5 to be placed in a cell,

    > which
    > > > t\will then insert 5 rows. Thanks

    > > Formula is what I am looking for, but I am getting a syntax error in the

    > line
    > > If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
    > > I have copied and pasted, should I be doing something else? Thanks

    >
    >
    > Yes, I am right clicking on sheet tab and clicking on View Code and then pasting in formula. Thgat line always comes up red and when I go to enter in the appropriate cells on the correct sheet I gfet the Compile Error - Syntax Error. Thanks


  6. #6
    Bob Phillips
    Guest

    Re: formula for inserting rows

    I am confused, it is fine here.

    You say you pasted the formula. What exactly have you copied in?

    --
    HTH

    Bob Phillips

    "Carol49" <[email protected]> wrote in message
    news:[email protected]...
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Have you inserted it in a worksheet code module as instructed?
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > "Carol49" <[email protected]> wrote in message
    > > news:[email protected]...
    > > >
    > > >
    > > > "Carol49" wrote:
    > > >
    > > > > Need formula that will allow a number e.g. 5 to be placed in a cell,

    > > which
    > > > > t\will then insert 5 rows. Thanks
    > > > Formula is what I am looking for, but I am getting a syntax error in

    the
    > > line
    > > > If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
    > > > I have copied and pasted, should I be doing something else? Thanks

    > >
    > >
    > > Yes, I am right clicking on sheet tab and clicking on View Code and then

    pasting in formula. Thgat line always comes up red and when I go to enter
    in the appropriate cells on the correct sheet I gfet the Compile Error -
    Syntax Error. Thanks



  7. #7
    Carol49
    Guest

    Re: formula for inserting rows



    "Bob Phillips" wrote:

    > I am confused, it is fine here.
    >
    > You say you pasted the formula. What exactly have you copied in?
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Carol49" <[email protected]> wrote in message
    > news:[email protected]...
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > Have you inserted it in a worksheet code module as instructed?
    > > >
    > > > --
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > "Carol49" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > >
    > > > >
    > > > > "Carol49" wrote:
    > > > >
    > > > > > Need formula that will allow a number e.g. 5 to be placed in a cell,
    > > > which
    > > > > > t\will then insert 5 rows. Thanks
    > > > > Formula is what I am looking for, but I am getting a syntax error in

    > the
    > > > line
    > > > > If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
    > > > > I have copied and pasted, should I be doing something else? Thanks
    > > >
    > > >
    > > > Yes, I am right clicking on sheet tab and clicking on View Code and then

    > pasting in formula. Thgat line always comes up red and when I go to enter
    > in the appropriate cells on the correct sheet I gfet the Compile Error -
    > Syntax Error. Thanks
    >
    >
    > I have tried from Private Worksheet.....

    also from On Error Go....
    and I stop after End Sub
    Thanks

+ 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