+ Reply to Thread
Results 1 to 7 of 7

Check value in a column, if condition is met, insert a row

  1. #1
    Registered User
    Join Date
    01-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    34

    Check value in a column, if condition is met, insert a row

    Hi,

    I need help on a macro that will:
    1. Check the values in column A, if they are equal, AND
    2. The sequential order of values in column B is either 6 then 7, or 2 then 6
    3. THEN insert a row, AND
    4. Enter the same column A value, AND the value "3" in column B

    Please see the attached spreadhseet for a visual explanation.

    I need a macro to perform this process for hundreds of thousands of row. I would greatly appreciate any help.

    Thank you!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Check value in a column, if condition is met, insert a row

    You could use the following - See attached workbook
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Registered User
    Join Date
    01-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Check value in a column, if condition is met, insert a row

    Hi Anthony,
    First, I just want to give you a big thanks for helping me with this task!

    I opened your attached spreadsheet and tried to run the macro, but it gets hung up on:

    Function Find_Range(Find_Item As Variant, _
    Search_Range As Range, _
    Optional LookIn As Variant, _
    Optional LookAt As Variant, _
    Optional MatchCase As Boolean) As Range

    Is there a way to make this work?

    Thank you!

  4. #4
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Check value in a column, if condition is met, insert a row

    I am not sure why you are having problems with the code - does it work in the workbook I uploaded? Anyway attached is a different function to create a collection of ranges containing the combinations you require. See how this works for you
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Check value in a column, if condition is met, insert a row

    It works perfectly Anthony!! Thank you so much!!!! You're awesome!

  6. #6
    Registered User
    Join Date
    01-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Check value in a column, if condition is met, insert a row

    Hi,

    Both of these previously submitted codes geniously done by Anthony work great...on less than 20,000 rows of data. The problem is I have over 300,000 rows of data, and probably need to use an array to manipulate the data. Is there a way to code the program so that it can handle a large amount of data?

    Thank you.

  7. #7
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Check value in a column, if condition is met, insert a row

    Is the problem that the code creates an error is is the problem that the processing time is too long. I would have thought that despite the number of rows you are working with that the code should cope however can you explain what the problem with the code is - it errors out/too long to run/???? - please describe the problem

+ 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