+ Reply to Thread
Results 1 to 11 of 11

Inputting new Headers and pulling data from other tables (same WB) into main table

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Inputting new Headers and pulling data from other tables (same WB) into main table

    This is part of a bigger project where I take 2-5 CRV files and automatically create tables (each named after the sheet name (with “_” instead of spaces) in each and merge them into one workbook. I have accomplished that (w/ help from this board). Now I want to take that workbook (Trackwise_7-22-2014) and add selected columns from the other tables to the correct cells of “query_export_results.” I will run the macro from “Importing Columns.xlsm. So,
    1. Add headers to the primary Table (query_export_results) as I list them in column B of Sheet1 of ImportingColumns1.xlsm. New columns just added to the right of the existing columns. In the example, these would be Product Code, Product Name and Cause Type in columns I, J and K (extending the table)
    2. Go down each new column in the Table and if the other table has a value for that row (based on PR ID), then enter it.
    a. This is made more complex because some other tables might have a PR ID listed more than once and in those cases, I want Excel to concatenate with commas or line breaks.
    I see this as some sort of CASE situation.
    So VBA goes through I2:I16 of table “query_export_results” (under heading “Product Code”). It has to know that product code is from table “Product_Information” so it looks there for matches and counts the number of times 900 appears (once). Then
    Case 0
    Enter “N/A”
    Case 1
    Enter value from “Product_Information
    Case >1
    Do a loop = Value & CHAR(010) & next Value

    Am I on the right track? I am in over my head. PR numbers will always be in order so multiples will always be in order and the query_ex… table does not ever contain duplicates.
    Questions?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    Hi ChemistB,

    This got it off the ground - but I've got to go out now (I renamed your books for this code):

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    Thanks XLAdept,
    From there I was able to replace the question marks at the end like so

    Please Login or Register  to view this content.
    That completes part 1. I read the selected fields off sheet1 and transfer them to the main table headers.

    Now part 2. Go to the appropriate tables for each of these headers and fill in the blanks on the main table. I will continue to work on it here. I appreciate the help!

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    Okay, so thinking through this is pseudo code
    For each cell in new columns going down
    For each PR number in table query_export_results
    In the table representing the current header (ITabR(I) )
    CountIF(Col 1 of Appropriate Table, =current PR)
    With CASE =0 then "NA",
    With CASE = 1 then enter value under same header
    With CASE >1 then loop and concatenate, then enter

    I just don't know enough VBA to do this with TABLEs, I might revert to used ranges and INDEX/MATCH

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    Hi ChemistB,

    Try this:

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    Close, when run on my example, it doesn't concatenate duplicates (or triplicates etc). For example, PR 908 has 2 entries in the Product_Information table but the code is only copying the first one. I need multiples concatenated, preferribly with line breaks between each. Hmmmm

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    Hi ChemistB,

    I had forgotten about the concatenations - here:

    Please Login or Register  to view this content.
    Thanks for the rep!

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    Excellent. This phase of my project is complete. Thanks for all your help XL

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    You're welcome, although I still feel indebted to you for past kindnesses

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    LOL, if you ever need a convoluted Formula approach, let me know.

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Inputting new Headers and pulling data from other tables (same WB) into main table

    Thanks - will do

+ 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. Need help pulling column headers based on table values (not max or min)
    By red5030 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-08-2014, 10:45 AM
  2. Uploading data into tables with a button click & pulling back the data from the table
    By tvsreekanth in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2013, 07:29 AM
  3. Pivot table not pulling column headers
    By joyhampton in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-18-2013, 11:21 PM
  4. [SOLVED] Creating Tables from a main table that is updating from an external source.
    By beat in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-15-2013, 09:20 AM
  5. Inputting data from multiple instances from multiple users into a main Excel Workbook
    By smooth_beaker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2013, 12:18 AM

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