+ Reply to Thread
Results 1 to 13 of 13

I need to fill 2 text columns based on criteria from 2 adjacent columns

  1. #1
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    I need to fill 2 text columns based on criteria from 2 adjacent columns

    Hi, I would like to know, if it's possible how to fill columns of specific text based on text criteria from adjacent columns.

    I receive a worksheet with around 4k-5k rows of data that I have to sift through manually editing as i go.

    In the attached sample the D column is related to L and E is related to M

    I was hoping that maybe i could use a a bit of code that would be able to recognise a combination of certain words in D and E and insert a new combination of the words i need in L and M

    i.e in D2-E2 we have Computers - Tablets, in L2-M2 i would like Notebooks-Tablets but in D5-E5 we have the word Computers again but this time it's paired with Desktops

    On the sheet is sample of how the completed solution should look.

    Hope someone can help me with this as it takes me hours of work every day addressing this issue.

    Kind regards
    John
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Hello again Johnny! Wow, you must spend all your time at work doing these tedious tasks. Hope this helps again.

    I've done the first two from your example, based on our back and forth yesterday I think you'll have no problem adding in the rest.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Hi walruseggman, Exactly what i was looking for, many many thanks.

    If you're ever in Donegal I'll buy you a Guiness.

    Thanks again
    Johnny

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Sounds great, and if you're ever in Texas you can buy me a Shiner.

    While we're at it, anything else you want automated? With what data I've seen from your spreadsheet so far, I don't think there's any reason for you to be doing anything manually by hand.

  5. #5
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    With what you've given me so far i'm well into getting it fully automated. I'm sure I'll come across another hurdle before i'm finished.

    Very appreciative and impressed with all your help.

    Will it be Ok to pm you if I do get to a hurdle I can't get over?

  6. #6
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Absolutely, a PM is fine.

  7. #7
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    I'm nearly there and i've been trying to adapt the code you provided without success. I need to do the following;

    In column I there's a list of codes;
    i.e.
    LJ452AV-SB39-FR
    LJ452AV-SB38-IT
    LJ450AV-SB30-DE
    LJ450AV-SB32-NL
    AU247AV-SB21
    VD484AV-SE-SB5
    LJ449AV-SB64-BE

    I need to remove everything from and including the first hyphen and the results to be shown in column J to look like the following
    i.e.

    LJ452AV
    LJ452AV
    LJ450AV
    LJ450AV
    AU247AV
    VD484AV
    LJ449AV

    The parts to be removed are all different apart from beginning with -SB**-** or -SB** or -SE**


    I truly appreciate all your help with this.

    Regards
    Johnny

  8. #8
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    So the code you need is refreshingly simple. I'll post that first, and then some details of what's going on in case you need to modify for later use.

    The code:

    Please Login or Register  to view this content.
    The explanation:

    So before we were using Left and Right for string manipulation. Those work great when
    a)You know the exact length of the string you want to extract, and
    b) the marker for what you want to extract (the R-Demo, RW, etc. or whatever it was) varies in length

    But here, we know the marker is the same every time (the dash, "-"), and we (might) have a variable and unknown length. So we can use split, which is faster than a Left and a Right, and I think easier to look at.

    How Split Works:

    Let's take a look at the example from my code:

    Please Login or Register  to view this content.
    Cell.Value: what you want split up. In this case is every value in row I
    "-": the string you want it to split at, what I was calling the marker. So in your first row, it will split Cell.Value into LJ452AV, SB39, and FR.
    (0): Which one of those split you want to keep. (0) is, somewhat confusingly, the first split. If we had used (2), cell J1 would have been "FR"

    Extra info that might come in handy:

    There is also an optional value for how many times you want it to split the string. The default, a not necessary to include -1, means it will split every time it sees the marker. You can also tell it to split a set number of times regardless of how many markers there are. An example:

    x = Split(Cell.Value, "-", 2)(0) would set x to:
    LJ452AV

    and

    x = Split(Cell.Value, "-", 2)(1) would set x to:
    SB39-FR


    as we are saying only split twice the first time you encounter a dash.
    Last edited by walruseggman; 11-02-2014 at 05:38 PM.

  9. #9
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Thank you just doesn't seem appropriate enough for the help you've given me.

    I'm now able to download the file, have it sorted and compared and then uploaded to our servers in less than a 3 minutes.

    Absolutely incredible work and the explanations have really helped me understand the procedure.

    Thanks again

    Johnny

  10. #10
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Glad to help. You'll have so much free time now!

  11. #11
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Would you mind if i picked your brains just one more time.

    In column C with I have rows of product descriptions that look similar to this;

    8770w i7-3630QM/4GB/500GB/DVDRW/17"HD+/W7P 64b WLAN/BT/CAM/FPR/GFX AMD FirePro M4000/W8P Lic

    Is it possible to extract portions of this text and place it other columns? i.e.

    4GB in column O with the word 'Core' as a prefix, 500GB with 'SATA' as the suffix in column P and 17" in column Q

    Many thanks

  12. #12
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Easy peasy with our old friend split.

    The 17" split first splits at the /, then splits again at the " of "HD" to capture the 17"HD+. There are so many quotes for syntax requirements of having quotes inside of quotes.

    So it basically splits at the " giving you 17, then I added the quote back in with: & """"

    Please Login or Register  to view this content.
    P.S. That's a nice laptop in your example. I'll take 3.
    Last edited by walruseggman; 11-04-2014 at 02:25 PM.

  13. #13
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: I need to fill 2 text columns based on criteria from 2 adjacent columns

    Running out of superlatives for you, once again many thanks, awesome help.

    Exactly what I was hoping for.

    Now to start working on my handicap

    Regards
    John

+ 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] fill down non-adjacent columns
    By elsg in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-10-2014, 03:39 PM
  2. Adding columns based off of adjacent columns.
    By smsulliva in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-10-2013, 12:26 PM
  3. [SOLVED] VBA fill in cells in a new column in table based on multiple criteria from other columns
    By HRA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-14-2013, 06:48 AM
  4. Replies: 1
    Last Post: 03-09-2013, 02:55 PM
  5. [SOLVED] Conditional Formatting Columns Based on Text from Adjacent Column
    By mejiamang in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-18-2012, 10:41 PM

Tags for this Thread

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