+ Reply to Thread
Results 1 to 4 of 4

how do I insert a row based on a function result

  1. #1
    chris
    Guest

    how do I insert a row based on a function result

    I want to run a a IF statement to qualify a row of data, and them if the
    condition is true, I want to insert a blank row below the current row where
    the fomula resides. I could also rework the formula to allow for the
    insertion of the blank row to be above the current row, as well. Either would
    work.

    Any assistance would be great!

  2. #2
    Dave Peterson
    Guest

    Re: how do I insert a row based on a function result

    Formulas can return values to the cell--they can't insert rows above (or below).

    chris wrote:
    >
    > I want to run a a IF statement to qualify a row of data, and them if the
    > condition is true, I want to insert a blank row below the current row where
    > the fomula resides. I could also rework the formula to allow for the
    > insertion of the blank row to be above the current row, as well. Either would
    > work.
    >
    > Any assistance would be great!


    --

    Dave Peterson

  3. #3
    chris
    Guest

    Re: how do I insert a row based on a function result



    "Dave Peterson" wrote:

    > Formulas can return values to the cell--they can't insert rows above (or below).
    >
    > chris wrote:
    > >
    > > I want to run a a IF statement to qualify a row of data, and them if the
    > > condition is true, I want to insert a blank row below the current row where
    > > the fomula resides. I could also rework the formula to allow for the
    > > insertion of the blank row to be above the current row, as well. Either would
    > > work.
    > >
    > > Any assistance would be great!

    >
    > --
    >
    > Dave Peterson
    >

    I understand. Then, is there a way to insert a blank row from a Macro.. one
    that would look at a one consistent cell within a row to qualify the
    insertion (ie...for any row where column A contains "X", then insert a row??

    Thanks.

  4. #4
    Dave Peterson
    Guest

    Re: how do I insert a row based on a function result

    Option Explicit
    Sub testme()

    Dim FirstRow As Long
    Dim LastRow As Long
    Dim iRow As Long
    Dim wks As Worksheet

    Set wks = Worksheets("sheet1")
    With wks
    FirstRow = 1
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

    For iRow = LastRow To FirstRow Step -1
    If LCase(.Cells(iRow, "A").Value) = LCase("x") Then
    .Rows(iRow + 1).EntireRow.Insert
    End If
    Next iRow
    End With

    End Sub

    Will insert a new row after if it finds an X in column A. (after that row).

    chris wrote:
    >
    > "Dave Peterson" wrote:
    >
    > > Formulas can return values to the cell--they can't insert rows above (or below).
    > >
    > > chris wrote:
    > > >
    > > > I want to run a a IF statement to qualify a row of data, and them if the
    > > > condition is true, I want to insert a blank row below the current row where
    > > > the fomula resides. I could also rework the formula to allow for the
    > > > insertion of the blank row to be above the current row, as well. Either would
    > > > work.
    > > >
    > > > Any assistance would be great!

    > >
    > > --
    > >
    > > Dave Peterson
    > >

    > I understand. Then, is there a way to insert a blank row from a Macro.. one
    > that would look at a one consistent cell within a row to qualify the
    > insertion (ie...for any row where column A contains "X", then insert a row??
    >
    > Thanks.


    --

    Dave Peterson

+ 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