+ Reply to Thread
Results 1 to 4 of 4

Add rows when needed

  1. #1
    Registered User
    Join Date
    12-23-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    19

    Add rows when needed

    I need help on figuring out some code please.
    In the attachment, there are 3 tables. Table 1 has the raw data in bold; which is the first 3 columns, A, B & C. This is the data that we import from our supplier into our workbook to get the result we need.
    The final data gets uploaded to our website as a CSV file. There are over 5000 products to filter through.
    My problem is, when I write the formula to extract the values from the LEFT side of the "-" in the Suppliers PN, it works okay. When I write the formula to extract the data from the RIGHT side of the "-", I don't get the same result. Notice column "E" in tables 1 & 2.
    I need the PN to the left withOUT the "-" in column "D" and I need the rest of the PN to the right of the "-" including the "-" in column "E" so I can CONCATENATE them with another cells data later.
    Table 2 is what we will have after all the formulas have performed their functions.
    Table 3 is the final result of what I need to save and convert to a CSV file for uploading. The bold items will be deleted from table 2 and the Italic cells will be save as the CSV.
    Column "G" is the PN I want to generate. If the number of characters to the left of the hyphen is <5, I need it to add "D0" to the existing portion to the left of the hyphen. If it is >5, just add "D".
    I hope I'm being clear about what I need. also, the "sku" is the PN for the parent product and it's children have the "-" and size. You will notice that the "parent sku" is the same value as the sku above. If the "parent sku" cell has a value, then "menu order" gets an advanced number besides "0" and the "Corrected Description" gets erased.
    I know there is an easy way to do this task.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,995

    Re: Add rows when needed

    Given that you have extracted column D, why not just use that to get column E?

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS
    Last edited by TMS; 12-04-2015 at 08:26 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,044

    Re: Add rows when needed

    Part of your problem here is the use of RIGHT() to get what you want.

    Think about how that works...
    It looks in a cell and takes the nth-right characters. But you are using FIND to locate how far from the LEFT "-" is, which has no bearing on how many characters are to the right of it. Look at the example below...
    K
    L
    M
    N
    3
    1-23456
    3
    456 23456
    4
    12-3456
    4
    3456 3456
    5
    123-456
    5
    3-456 456
    6
    1234-56
    6
    234-56 56
    7
    12345-6
    7
    12345-6 6

    L3=FIND("-",K3,1)+1
    M3=RIGHT(K3,L3)
    or, combined...=RIGHT(K3,FIND("-",K3,1)+1)
    copied down

    From this you can see that the postion (from the left) of the "-" gets greater as it moves "deeper" into the string, so using that postion to return what is to the right of it just simply does not make sense

    You need to use the MID finction for this...
    N3=MID(K3,FIND("-",K3,1)+1,99)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    12-23-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Add rows when needed

    Thanks FDibbins, I'll give it a try and let you know the outcome.
    Many thanks.

+ 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. [SOLVED] VBA needed for inserting rows
    By rcocalm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2015, 09:50 AM
  2. [SOLVED] VBA to add up Total # or rows to populate Destination sheet and insert More Rows if needed
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-29-2014, 08:44 PM
  3. Help needed with selecting rows
    By road rash ninja in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-14-2014, 11:37 PM
  4. VBA needed for copying rows
    By akita in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2013, 10:42 AM
  5. It copy one row only not all needed rows
    By suny100 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-02-2012, 01:00 PM
  6. Help needed to combine rows
    By shreksbro in forum Excel General
    Replies: 2
    Last Post: 05-08-2012, 03:39 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