+ Reply to Thread
Results 1 to 6 of 6

Convert data (a bit like a FOREACH?)

  1. #1
    Registered User
    Join Date
    03-03-2016
    Location
    London
    MS-Off Ver
    15
    Posts
    8

    Red face Convert data (a bit like a FOREACH?)

    Hello,

    Keen Excel user here trying to do something a little bit out of his skill set!

    I have a spreadsheet with the info below. Every person will sign up for swimming (23442) but they can then optionally sign up for UP TO 7 other sports. If they have signed up for something else then there will be another entry in the spreadsheet.

    Please Login or Register  to view this content.
    I need to change the above so that each person is only on one line - something like:

    Please Login or Register  to view this content.
    Any help gratefully appreciated! I'm certain I can do it but it's driving me bonkers!

    Thanks
    Attached Files Attached Files

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

    Re: Convert data (a bit like a FOREACH?)

    If you want the event names added, you're going to need to provide a complete event id / event name lookup table. This code does not add event names for that reason.

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Registered User
    Join Date
    03-03-2016
    Location
    London
    MS-Off Ver
    15
    Posts
    8

    Re: Convert data (a bit like a FOREACH?)

    Oh walruseggman that's just awesome! I remember doing VB stuff years ago and that all makes sense - I've just never applied it to Excel and look forward to learning more.

    The code works great - thank you so much!

  4. #4
    Registered User
    Join Date
    03-03-2016
    Location
    London
    MS-Off Ver
    15
    Posts
    8

    Re: Convert data (a bit like a FOREACH?)

    OK I tried to do the event name lookup but failed miserably

    If I had another sheet ("events")with the event IDs/event names in, how would I alter the above code to replace the event IDs with the event name?

    So the "events" sheet would be simply:

    Please Login or Register  to view this content.
    I've been reading about VLOOKUP but can't work out how to integrate it with the above code.

    Any help welcome!

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

    Re: Convert data (a bit like a FOREACH?)

    I'm more inclined to use Range.Find then Vlookup, if only because I'm more familiar with it. If you have a massive data set to search (like 100,000+ rows), then I've seen that Vlookup can be faster. Otherwise it doesn't really matter.

    Please note I've changed the sub as well as added the Function. Also assumes event id's are in column A on "events" sheet. If not, adjust Columns(1) in the function.


    Please Login or Register  to view this content.
    Last edited by walruseggman; 03-04-2016 at 01:40 PM.

  6. #6
    Registered User
    Join Date
    03-03-2016
    Location
    London
    MS-Off Ver
    15
    Posts
    8

    Re: Convert data (a bit like a FOREACH?)

    Thanks again walruseggman - just perfect

+ 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. Replies: 3
    Last Post: 09-15-2015, 06:07 AM
  2. Excel 2007 Sumproduct foreach day in column?
    By jrider64 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-29-2015, 02:27 PM
  3. VBA Code convert data to tab delimited and write data to text file | Not Working
    By lbl159 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2015, 06:40 AM
  4. Foreach Name in a List Paste a Template of Cells
    By Codeman553 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2013, 10:25 AM
  5. [SOLVED] Foreach loop lookup between two worksheets
    By asparak in forum Excel General
    Replies: 7
    Last Post: 07-14-2012, 05:03 AM
  6. Replies: 2
    Last Post: 06-25-2012, 12:24 PM
  7. [SOLVED] ForEach statement problem
    By excelnut1954 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2006, 05:40 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