+ Reply to Thread
Results 1 to 4 of 4

inserting a row based on a condition.

  1. #1
    Gary
    Guest

    inserting a row based on a condition.

    i need a macro to do the following.

    if value in cell is >=x then insert a row above.

    Possible?



  2. #2
    Richard Buttrey
    Guest

    Re: inserting a row based on a condition.

    On Fri, 18 Aug 2006 05:25:15 -0600, "Gary" <[email protected]>
    wrote:

    >i need a macro to do the following.
    >
    >if value in cell is >=x then insert a row above.
    >
    >Possible?



    Yes, but you need to give some more details as to how this is intended
    to operate.

    i.e. Are you referring to just a single cell such that when its value
    changes to be greater than x, the row is inserted, or are you trying
    to loop down a column of cells and wanting to insert several rows if
    the condition is met?

    If the former, do you want this to kick in once only, or every time x
    is changed so that a row might be inserted several times if the
    condition is met

    Rgds


    __
    Richard Buttrey
    Grappenhall, Cheshire, UK
    __________________________

  3. #3
    Gary
    Guest

    Re: inserting a row based on a condition.

    Sorry for not being clear Richard. What I want is whenever the in any cell
    in column A is >=x, the macro should insert a row right above that row.

    For example - if i enter x in A14, the macro should insert a row above. now
    A14 will automatically become A15.

    thanks in advance.

    "Richard Buttrey" <[email protected]> wrote in
    message news:[email protected]...
    > On Fri, 18 Aug 2006 05:25:15 -0600, "Gary" <[email protected]>
    > wrote:
    >
    >>i need a macro to do the following.
    >>
    >>if value in cell is >=x then insert a row above.
    >>
    >>Possible?

    >
    >
    > Yes, but you need to give some more details as to how this is intended
    > to operate.
    >
    > i.e. Are you referring to just a single cell such that when its value
    > changes to be greater than x, the row is inserted, or are you trying
    > to loop down a column of cells and wanting to insert several rows if
    > the condition is met?
    >
    > If the former, do you want this to kick in once only, or every time x
    > is changed so that a row might be inserted several times if the
    > condition is met
    >
    > Rgds
    >
    >
    > __
    > Richard Buttrey
    > Grappenhall, Cheshire, UK
    > __________________________




  4. #4
    Richard Buttrey
    Guest

    Re: inserting a row based on a condition.



    Put the following in the worksheet_change event procedure



    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
    If Target = "x" Then
    Target.EntireRow.Insert
    End If
    End If
    End Sub


    I wasn't quite sure if you really meant >= x or just >x

    The above will insert a row only if you enter an 'x' in column A.
    If you really do mean >= x, i.e a row is inserted if you enter x, y or
    z then just change the ="x" to >="x"

    HTH




    On Fri, 18 Aug 2006 06:00:51 -0600, "Gary" <[email protected]>
    wrote:

    >Sorry for not being clear Richard. What I want is whenever the in any cell
    >in column A is >=x, the macro should insert a row right above that row.
    >
    >For example - if i enter x in A14, the macro should insert a row above. now
    >A14 will automatically become A15.
    >
    >thanks in advance.
    >
    >"Richard Buttrey" <[email protected]> wrote in
    >message news:[email protected]...
    >> On Fri, 18 Aug 2006 05:25:15 -0600, "Gary" <[email protected]>
    >> wrote:
    >>
    >>>i need a macro to do the following.
    >>>
    >>>if value in cell is >=x then insert a row above.
    >>>
    >>>Possible?

    >>
    >>
    >> Yes, but you need to give some more details as to how this is intended
    >> to operate.
    >>
    >> i.e. Are you referring to just a single cell such that when its value
    >> changes to be greater than x, the row is inserted, or are you trying
    >> to loop down a column of cells and wanting to insert several rows if
    >> the condition is met?
    >>
    >> If the former, do you want this to kick in once only, or every time x
    >> is changed so that a row might be inserted several times if the
    >> condition is met
    >>
    >> Rgds
    >>
    >>
    >> __
    >> Richard Buttrey
    >> Grappenhall, Cheshire, UK
    >> __________________________

    >


    __
    Richard Buttrey
    Grappenhall, Cheshire, UK
    __________________________

+ 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