+ Reply to Thread
Results 1 to 16 of 16

string processing

  1. #1
    Registered User
    Join Date
    05-09-2008
    Posts
    9

    string processing

    Hi!

    Let's say I have a table (one column):

    Item name
    Blah bb/gg 2/3/4
    Hlab ji/lk 10/50
    Shlim 67/pp 45/56-90

    The script/macro/I-don't-know-what would fill out this table (I added three new column):
    Item name Width Height Length
    Blah bb/gg 2/3/4 2 3 4
    Hlab ji/lk 10/50 10 50 0
    Shlim 67/pp 45/56-90 45 56-90 0

    Basically, what it does is that it looks for the '/' char and recognizes the strings around it. It skips the first two strings from the right (they are a part of the name) and records the next 3 strings which are usually numbers (or like "56-90") and places them each into his own cell.

    The task I have is to take these "Item names" and extract the size data out of them, for example:
    Hlab ji/lk 10/50 is an item called hlab ji/lk with measurements 10 by 50 by 0 and each of these measurements has to go to it's own cell for each line.

    If it's too much for you to just reveal to me as a ready solution, I would appreciate any direction on how I can make a solution.

    Thanks. Tod.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Could you put these strings in column A in worksheet, and in columns to the right enter the strings you expect to see. Then upload the workbook to the forum. It's always easier if we can see the problem in context.

    Rgds

  3. #3
    Forum Contributor
    Join Date
    10-08-2006
    Location
    Walnut, CA
    MS-Off Ver
    2003,2010, Office 365
    Posts
    114
    Hi,
    Something like this?
    Please Login or Register  to view this content.
    Tony

  4. #4
    Registered User
    Join Date
    05-09-2008
    Posts
    9
    I am surprised of your willingness to help.
    Here's a pic if you are not willing to open an Excel file made by someone else
    or if I screwed up something:
    http://img180.imageshack.us/img180/3015/picaz5.jpg

    Blue is the input data, green is the automatically generated form.

    Tell you the truth, I can do it manually but I would really like to learn Excel and help other just as much as you are helping me so your efforts are in fact going to help this community in the long run.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-09-2008
    Posts
    9
    Tony, I am new to Excel and I just switched to 2007 which made things even worse. Could you tell me what to do with that code?

  6. #6
    Registered User
    Join Date
    05-09-2008
    Posts
    9
    Tony, I played around a little and actually got something useful!
    I think if I play some more I can get something absolutely working!

  7. #7
    Registered User
    Join Date
    05-09-2008
    Posts
    9
    what bothers me about it is that it works but it projects the results in the column right next to it.

    How do I change this program so that I can choose which column do the results go?

    I am too spoiled. I should start hitting the books but I have so much on my mind and my conscience keeps telling me "ask Tony... Ask Tony..."

  8. #8
    Forum Contributor
    Join Date
    10-08-2006
    Location
    Walnut, CA
    MS-Off Ver
    2003,2010, Office 365
    Posts
    114
    Hi,
    I'm using Excel 2003. If you can open the xls with 2003, run the Macro “SplitTest” on the attached file should get you the result.

    I’ll try to explain the code a little bit.

    X = Split(“Blah bb/gg 2/3/4”,”/”) will result
    X(0)= “Blah bb”
    X(1)= “gg 2”
    X(2) = “3”
    X(3) = “4”

    Use InStrRev() and Right() to change x(1) to “2”
    Output X(1)~X(3) to column C,D,E

    Hope this helps!
    Tony
    Attached Files Attached Files

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    See attached workbook.

    Rgds
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-09-2008
    Posts
    9
    It does help a lot. In the short run, I can get the job done and in the long run I have a base on which I can develop more skills.

    I am still not entirely fluent with the code but maybe it's because I didn't even start learning VBA?

    SOLVED.

    T H A N K S

  11. #11
    Registered User
    Join Date
    05-09-2008
    Posts
    9
    Hi!

    My brother wants to know
    1. What happens if the source data is formed like:
    Blah bb/gg 2/3/4 Blah
    It doesn't work in that case, neither the elegant Macro nor the Uber Haxx Excel cell formula.
    2. Can a macro be made that checks the source data and deletes the entries will less than 3 '/'s?

    Working practically 24/7 this month. I wish I had time to experiment with it at home.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    UDF
    select C3:E3 and type =Mustey(A3)
    then confirm with Ctrl + Shift + Enter (array formula entry)
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    05-09-2008
    Posts
    9
    Thank you very much Jindon. Please let me know how do I use that code you have so kindly provided me? I have no idea where to enter it.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    1) hit Alt + F11
    2) go to [Insert] - [Module] then paste the code onto the right pane
    3) hit Alt + F11 to get back to Excel
    4) select any horizontal 3 cells
    5) enter formula =mustey(A1)
    6) confirm with Ctrl + Shift + Enter (array formula entry)
    Following code is adjusted to work with
    "abs w/d 22/30-40/50-60 derf" returns 22, 30-40, 50-60 in individual cell
    Please Login or Register  to view this content.
    Last edited by jindon; 05-10-2008 at 08:41 AM.

  15. #15
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Just one caveat.
    The code includes a 'Split' command. Unfortunately this command isn't part of the VBA set for Microsoft Excel 2004 for Mac.

    Seems it's only available in the Windows version.

    Rgds

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Mac ?
    If you only want Split function, there's a code I wrote for xl95, however I don't think you can set the reference to WSH RegExp anyway.

    Bad luck.

+ 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