+ Reply to Thread
Results 1 to 9 of 9

consolidate values in each record according to a specific structure

  1. #1
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    consolidate values in each record according to a specific structure

    Hello,

    Interesting project for the VBA guru! I have an excel file that is extracted from a database with a structure that stays consistent throughout the excel file. Please open the example workbook, and while reading this post you can view the example and see what I am talking about. If you don't open the file, you will most likely not know what I am trying to describe as it can be confusing.

    Column H is the output of what I need the VBA code to do with the giving columns (A:G). The extracted file from the database will include a similar structure to what I have provided in columns A:G. However, the actual extract does have the same structure, but goes through column J. It is possible to have multiple categories in the same column that should have the EXACT same structure in column H.

    Ideally, I would like to have the output (that is currently in column H), show up in column K as the actual data set I will use with this code goes from column A to column J.

    Please let me know if you have any questions as to what I need. Thank you!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: consolidate values in each record according to a specific structure

    Is there any reason why you don't use the "text to columns" option on the data tab. Use "delimited" with / as a delimiter?

    You don't provide enough context about why and how you would want to do this to decide how to approach the VBA


    click on the * Add Reputation if this was useful or entertaining.

  3. #3
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Re: consolidate values in each record according to a specific structure

    Hey tony,

    I apologize if I wasn't clear. Text to columns will not work in my case as column H is not part of the database extract. I have reformatted the example workbook with some colors:

    Yellow: Database extract
    Green: Output I need the VBA to do with the database extract

    Explanation of Database Extract:
    *column A (League) --> This value will be the first value in column H that is before the first "/"
    *column B (Team#) --> This value will be the second value in column H AFTER the first "/"
    *column C (Position#) --> This value will be the third value in column H AFTER the SECOND "/"
    ...
    ...
    This order stays consistent. However, please take notice that if Team # changes then the strings below the Team# is part of the team structure. Every time the Team# changes, then the strings below the Team# will be paired with this particular Team#. The organizational breakdown structure is consistent with the change. I hope this clears any confusion. If it doesn't and you need more clear descriptions as to what the VBA code needs to accomplish, please let me know. Thank you for all of your help with this!
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: consolidate values in each record according to a specific structure

    I'm giving up for today.

    That explanation helps but you don't explain how the sheet is populated and when the VBA should run. Whether it is automatic or whether someone chooses to run it. Is the number of rows fixed etc

  5. #5
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Re: consolidate values in each record according to a specific structure

    Hey Tony,

    Thank you for your help on this as it is much appreciated! Again, I do apologize if I haven't explained enough of the specifics in order for you to approach how to write the VBA coding. Please see the answers to your questions below:

    1) How the sheet is populated:
    - I export a query from a database which results in an excel file similar to the yellow highlighted columns.

    2) VBA should run:
    - The VBA will be executed by someone clicking a button to execute the procedure

    3) Number of records in database extract:
    - The number of records in the database extract will always vary. As of right now, the file goes to about 3,000 records (of which are all in the same format I provided, however the number of columns in the actual database extract is from A:J, whereas the file I provided goes from A:G --> However, the format of the merged cells with subcategories is the same format I have provided)

    I hope this helps. If it doesn't please don't hesitate to ask any more questions! Thank you again

  6. #6
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Re: consolidate values in each record according to a specific structure

    Hey Tony,

    Did the previous explanation help?

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: consolidate values in each record according to a specific structure

    Maybe:

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Re: consolidate values in each record according to a specific structure

    Hey JOHN H. DAVIS,

    This is EXTREMELY close! There are several instances where the organization breakdown structure can come back towards column A and still remain under a particular team. The VBA code currently doesn't know how to handle this and the code will stop running. Please see the new uploaded workbook to see what it is I am referencing (see Team4, the darker colors is what I have added that you haven't seen).

    One other thing to note, in the code -- instead of searching for "Team", can we make it dynamic to whatever the value is in column B starts a new Team. In other words, the database extract I have doesn't contain the word "Team". It is safe to assume that if there is a new value contained in column B, then it starts a new team organization breakdown structure. I hope this makes sense...if it doesn't please let me know and I can provide a better explanation.

    Thank you for your help John! You are the man..SERIOUSLY!
    Attached Files Attached Files
    Last edited by bcn1988; 09-17-2013 at 02:22 PM.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: consolidate values in each record according to a specific structure

    Maybe:

    Please Login or Register  to view this content.

+ 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: 02-25-2013, 08:11 AM
  2. Replies: 1
    Last Post: 11-07-2012, 02:00 AM
  3. How to structure lots of fields as one record.
    By Cboggie in forum Access Tables & Databases
    Replies: 6
    Last Post: 07-12-2012, 03:26 PM
  4. Replies: 6
    Last Post: 05-30-2012, 01:46 PM
  5. Open files within specific file structure
    By GregR in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-18-2005, 03:05 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