+ Reply to Thread
Results 1 to 9 of 9

Insert a new row if cell contains certain characters

  1. #1
    Registered User
    Join Date
    03-05-2014
    Location
    North Carolina, USA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Insert a new row if cell contains certain characters

    Good morning,

    I just need a little help to get started with a project I'm working on. I'm trying to transform a Excel spreadsheet that is used for reference and turning it into a file that can be imported into Access.

    We have an old billing system and it contains codes that we use to determine a service package. The problem is that one code can be used for multiple packages.

    There is an example of what I mean....

    Site BillCode Package
    NYC X123 6 months @ $19.95
    NYC Y987 3 months free & 6 months @ 19.95
    NYC G555 1 month free + 3 months @ 15.99 + 6 months @ 19.95


    What I want to do is have a macro that will evaluate if there are any "+" or "&" in the last column of the row, if there is, I want to copy this row and insert it on the next line so that is looks like this.


    Site BillCode Package
    NYC X123 6 months @ $19.95
    NYC Y987 3 months free & 6 months @ 19.95
    NYC Y987 3 months free & 6 months @ 19.95
    NYC G555 1 month free + 3 months @ 15.99 + 6 months @ 19.95
    NYC G555 1 month free + 3 months @ 15.99 + 6 months @ 19.95
    NYC G555 1 month free + 3 months @ 15.99 + 6 months @ 19.95

    My reason to do this is that I want each code to have 1 package. If a code has more than one package, I need to create as many rows to accomdate each package that it comes with. So my logic is for the macro to count how many "+" or "&" there are in the last cell and create X number of rows. So if the cell contains one "+", copy the row and insert it below. If it contains 2 "&", then copy the row and insert it below 2 times. And so on.

    Ultimately, my goal is to have the spreadsheet look like this, but I realize that may be hard to do, so I'm willing to go in and manually fix this last part to have it where I want it.


    Site BillCode Package
    NYC X123 6 months @ $19.95
    NYC Y987 3 months free
    NYC Y987 6 months @ 19.95
    NYC G555 1 month free
    NYC G555 3 months @ 15.99
    NYC G555 6 months @ 19.95


    Any help will be greatly appreciated. By the way, I'm using Excel 2010.
    Last edited by jujudondon; 03-05-2014 at 12:01 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,619

    Re: Insert a new row if cell contains certain characters

    And here goes my proposition ("do_it_all") in small body:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Insert a new row if cell contains certain characters

    or
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-05-2014
    Location
    North Carolina, USA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Insert a new row if cell contains certain characters

    Thanks everyone...both solutions worked like a charm! Thanks for giving me a spring board to resolve this issue.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Insert a new row if cell contains certain characters

    Maybe:

    Please Login or Register  to view this content.
    Assumes you have 3 columns as in your sample.

  6. #6
    Registered User
    Join Date
    03-05-2014
    Location
    North Carolina, USA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Insert a new row if cell contains certain characters

    If I have more, what would I need to change?

  7. #7
    Registered User
    Join Date
    03-05-2014
    Location
    North Carolina, USA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Insert a new row if cell contains certain characters

    One last question, nilem....

    What values would I change if I have more than 3 columns and I need to look in a different column other than "C"?

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Insert a new row if cell contains certain characters

    Would your Package Column be D?

  9. #9
    Registered User
    Join Date
    03-05-2014
    Location
    North Carolina, USA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Insert a new row if cell contains certain characters

    No, column J

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Locate cells with certain characters and insert new cell
    By Sweepin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2013, 02:08 AM
  2. Insert text between characters in a cell.
    By CastorRJ1 in forum Excel General
    Replies: 2
    Last Post: 03-01-2010, 06:11 PM
  3. insert characters
    By franciz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-30-2008, 02:01 PM
  4. [SOLVED] Insert Characters in cell with formatted text
    By MichaB in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-17-2006, 08:25 AM
  5. How to insert Asian characters into a cell?
    By Andrew in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2005, 06:36 AM

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