+ Reply to Thread
Results 1 to 5 of 5

Text to value in column

  1. #1
    Registered User
    Join Date
    10-22-2014
    Location
    Amsterdam
    MS-Off Ver
    2010
    Posts
    21

    Text to value in column

    Hi, my name is Marc and I hope somebody can help me creating a VBA for my problem. I have included a file with the problem.
    See the Sheet Example.
    So I have a Sheet with 2 columns the first column contains the movie_id number, the second column contains the corresponding genres of the movie as text in a single cell that is separated by a comma (,).
    Both columns always have the same length but the length of both columns, in this case row 119, is a variable.
    The text, separated by a comma, in the second column corresponds with the text in the sheet tbl_genres. Every text part is corresponding with a value (genre_id) in the Sheet tbl_genre. For example: action = 1; adventure =2; animation=3.

    So the first row in the example:
    4029 action, drama, history, thriller, war

    can be translated to:
    4029 1,8,12,18,19

    But in fact every genre_id in that row corresponds with the same movie_id number. So for the first row, 4 new rows (total of 5 rows for the corresponding 5 genre_id’s) must be created to make a relation between the movie_id and the 5 genre's.
    4029 1
    4029 8
    4029 12
    4029 18
    4029 19

    Sometimes a cell in the second column is empty (no corresponding text/genre), In that case the row (and corresponding movie_id number) must be deleted.

    In the example file I have included the sheet Result with the result for the first 7 movie_id numbers.
    Hope my explanation is clear, if not feel free to contact me so I can explain some more.
    Thanks in advance for all your help.
    Marc
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-12-2017
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    59

    Re: Text to value in column

    Hello.
    See if this is what you want:


    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Text to value in column

    And another variant ...
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Text to value in column

    Always test in a backup copy but especially so for overwrite macros like this.
    Please Login or Register  to view this content.
    Last edited by Kenneth Hobson; 11-04-2017 at 01:21 PM.

  5. #5
    Registered User
    Join Date
    10-22-2014
    Location
    Amsterdam
    MS-Off Ver
    2010
    Posts
    21

    Re: Text to value in column

    Gfranco,
    Your the BEST!
    Exactly what i wanted!
    Thanks so much!!

    porucha vevrku and Kenneth Hobson also thanks for your work, haven't tested this yet, but it's much apreciated!
    Marc

+ 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] Macro to Copy and Paste Specific Text in Column A on the last line with Text in Column B?
    By D2S in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2017, 04:08 PM
  2. [SOLVED] VBA Macro to find text string in one column and replace specific text in another column if
    By bmahfood in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-21-2017, 11:15 AM
  3. Replies: 3
    Last Post: 04-21-2016, 02:52 AM
  4. Filter column by text, then export column to new workbook, replace searched text with new.
    By Headhunter234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2015, 07:48 AM
  5. Text&number based column to auto display new text in new column
    By TCF in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-24-2014, 01:56 PM
  6. Replies: 12
    Last Post: 01-08-2014, 11:28 AM
  7. Trying to write amacro to compare text in column A to garbage text in column B
    By Big Dawg Dad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2013, 03:31 PM

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