+ Reply to Thread
Results 1 to 17 of 17

Extend the number of unique keys in a table

  1. #1
    Registered User
    Join Date
    04-09-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    12

    Lightbulb Extend the number of unique keys in a table

    Hello everyone,

    I hope there is someone out there who can help with the follwoing problem.

    I have table containg 2 primary keys (From Warehouse and Delivery Method).

    From Warehouse-Delivery Method Lead Time

    US D001 x
    US D002
    US D003
    US D004
    US D005
    etc etc

    This table how now changed to including 3 primary keys:


    From Warehouse-Delivery Method-To Warehouse

    US D001 Sweden
    US D002 Sweden
    US D003 Sweden
    US D004 Sweden
    US D005 Sweden
    US D001 Germany
    US D002 Germany
    US D003 Germany
    US D004 Germany
    US D005 Germany
    US D001 ITALY
    US D002 ITALY
    US D003 ITALY
    US D004 ITALY
    US D005 ITALY
    US D001 CANADA
    US D002 CANADA
    US D003 CANADA
    US D004 CANADA
    US D005 CANADA
    etc etc etc

    What I want to do is per unique From Warehouse-Delivery method be able to add To Warehouse values so they table looks like above. is this possible?
    Attached Files Attached Files
    Last edited by mikal.malmberg; 12-16-2014 at 02:17 PM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Script/macro to

    Sorry, I am not sure, are you asking for a macro that will do this? all I see is a sheet with some data. isn't column D-F exacly what you you are asking for, just with "A01" as "from warehouse" instead of "US"?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Script/macro to

    Do you mean K1 & K2 & K3?

    US D001 SWEDEN
    US D002 SWEDEN
    US D003 SWEDEN
    US D004 SWEDEN
    US D005 SWEDEN
    US D006 SWEDEN
    US D007 SWEDEN
    US D008 SWEDEN
    US D009 SWEDEN
    US D010 SWEDEN
    US D011 SWEDEN
    US D012 SWEDEN
    US D013 SWEDEN
    US D014 SWEDEN
    US D015 SWEDEN
    US D016 SWEDEN
    US D017 SWEDEN
    US D001 GERMANY
    US D002 GERMANY
    US D003 GERMANY
    US D004 GERMANY
    US D005 GERMANY
    US D006 GERMANY
    US D007 GERMANY
    US D008 GERMANY
    US D009 GERMANY
    US D010 GERMANY
    US D011 GERMANY
    US D012 GERMANY
    US D013 GERMANY
    US D014 GERMANY
    US D015 GERMANY
    US D016 GERMANY
    US D017 GERMANY
    US D001 UK
    US D002 UK
    US D003 UK
    US D004 UK
    US D005 UK
    US D006 UK
    US D007 UK
    US D008 UK
    US D009 UK
    US D010 UK
    US D011 UK
    US D012 UK
    US D013 UK
    US D014 UK
    US D015 UK
    US D016 UK
    US D017 UK
    US D001 ITALY
    US D002 ITALY
    US D003 ITALY
    US D004 ITALY
    US D005 ITALY
    US D006 ITALY
    US D007 ITALY
    US D008 ITALY
    US D009 ITALY
    US D010 ITALY
    US D011 ITALY
    US D012 ITALY
    US D013 ITALY
    US D014 ITALY
    US D015 ITALY
    US D016 ITALY
    US D017 ITALY
    Last edited by mehmetcik; 12-16-2014 at 02:03 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Registered User
    Join Date
    04-09-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Script/macro to

    Sorry,

    coloum D should be US, not A01. I want to extened the number of keys by having a macro that inserts the third new key (i.e. to warehouse). Do you understand now? I like help to create a script that makes this possible, thankful for all help I can get.

  5. #5
    Registered User
    Join Date
    05-24-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Script/macro to

    you mean how you can add a value in K2 and add automatically in k1 and they also automatically sort ?

  6. #6
    Registered User
    Join Date
    04-09-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Script/macro to

    No, just a the K3-colulmn for all "To Warehouse".

    Table with 2keys:

    From Warehouse-Delivery Method

    US D001
    US D002
    US D003
    US D004
    US D005

    The macro should then be able to add all the To Warehouse for all combination of key 1 and 2.

    From Warehouse-Delivery Method To Warehouse

    US D001 SWEDEN
    US D002 SWEDEN
    US D003 SWEDEN
    US D004 SWEDEN
    US D005 SWEDEN
    US D001 ITALY
    US D002 ITALY
    US D003 ITALY
    US D004 ITALY
    US D005 ITALY

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Script/macro to

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  8. #8
    Registered User
    Join Date
    04-09-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Script/macro to

    I have updated the title, can you please re-open?

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Extend the number of unique keys in a table

    Ok I have looked at this again

    You have an existing excel table with two keys.

    You now want to add a third key. So left click in the table, right click and select insert column to the right.

    Now you can paste your new column data into the third column.

  10. #10
    Registered User
    Join Date
    04-09-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Extend the number of unique keys in a table

    I think you missunderstand me. I know how to add a column a paste data.

    The issue I have is that the table currentley have two primary keys; From Warehouse and Delivery Method, that should now be extened to hold three keys; From Warehouse, Delivery Method and To Warehouse. I can of course add the new column To Warehouse manually, but what i need is a script/macro/function that insert all To Warehouses for all the different from warehouse and delivery methods combinations get all the new combinations generated.

  11. #11
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Extend the number of unique keys in a table

    Please find the attached sheet and click on the Green Button to run the code to see if this is what you are trying to achieve.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    04-09-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Extend the number of unique keys in a table

    Thank you so much sir, the only thing that I want to change is that I want the information be seperate in three new columns? Is this possibl? i.e. not in ONE column?

  13. #13
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Extend the number of unique keys in a table

    Please find the attache sheet.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    04-09-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Extend the number of unique keys in a table

    Thank you! Almost what I want, please look at the attached file.
    Attached Files Attached Files

  15. #15
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Extend the number of unique keys in a table

    See the attached.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    04-09-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Extend the number of unique keys in a table

    Thank you very much Sktneer!

  17. #17
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Extend the number of unique keys in a table

    You're welcome.

+ 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. script to run the macro from Vb script with out opening the excel file
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2021, 03:33 AM
  2. calling the vb script from the shell script(unix platform)
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2014, 06:21 AM
  3. Integrating Mainframe emulator script with excel's vba script
    By Himanshu Mishra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2012, 10:30 AM
  4. Create VBA script to short, dedicated button in excel for script?
    By realized in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2009, 11:54 PM
  5. Script that edits the text printed on the button that runs the script
    By petalred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2008, 02:41 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