+ Reply to Thread
Results 1 to 9 of 9

VBA newbie... need help with taking user input from worksheet and creating new table

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    VBA newbie... need help with taking user input from worksheet and creating new table

    Hi all,

    I'm just starting to learn VBA and hope that you can serve as resources for what I need to do now and in the future.

    I've attached a sample file to talk through this problem.

    I have some user inputs of "NAME," various "SIZES" and "PRICES". For 1 NAME, there are many corresponding sizes/prices. The idea is that the user would type all of this in by him/herself. Then, press a button and have a new table created, as shown in the example. The table is sorted by Sizes.

    To make the new table, I wanted to first grab all of the possible values in the size column, sort, then get rid of duplicates. After that, make a lookup table of some sort. I'm just not sure how to go about doing this.

    Thanks!

    example.xlsx

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA newbie... need help with taking user input from worksheet and creating new table

    How about a pivot table? : example.xlsx
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: VBA newbie... need help with taking user input from worksheet and creating new table

    that looks great!

    i was wondering if adding the following would be possible:

    instead of only the column SIZE, let's say there's another options column, OPTIONS with strings instead of numbers, i.e. A, B, C.

    The new user inputs would be like

    SIZE OPTIONS
    3 A
    4
    5 B

    And I want the pivot tables to still sort by Sizes, but for those with OPTIONS, show up as 2, 3, 3A, 4, 5, 5B, and so on.

    How difficult would that be?

    thanks again.

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA newbie... need help with taking user input from worksheet and creating new table

    like this? example.xlsx

  5. #5
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: VBA newbie... need help with taking user input from worksheet and creating new table

    Quote Originally Posted by tehneXus View Post
    yea, sort of. but I really want the final pivot table to actually have the strings 2, 3, 3A, 4, 4A, etc. The reason I wanted to do this is because in another future step, I want to plot 2, 3, 3A, 4, 4A, etc, as individual separate bars. By separating NAME and OPTION in the pivot table, it makes it harder to graph in the end, right? just wanted to see if both NAME + OPTION can be treated as a string.

  6. #6
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA newbie... need help with taking user input from worksheet and creating new table

    Clarification: is it Name + Options or Size + Options?

    You won't be able to merge 2 columns into 1 in a pivot table, do you really need this? how should the graph look like?

  7. #7
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: VBA newbie... need help with taking user input from worksheet and creating new table

    Quote Originally Posted by tehneXus View Post
    Clarification: is it Name + Options or Size + Options?

    You won't be able to merge 2 columns into 1 in a pivot table, do you really need this? how should the graph look like?
    oh, sorry, yes - it is Size + Options.

    and unfortunately, I do need this. they're just eventually going to become portions of some bar graphs, where size+option actually becomes one of the variables I want to look at.

    maybe there is some macro to write, to pre-populate the original table prior to making the pivot table? grab all the info to column Size and column Option and merge them together into a separate table, then make a pivot table? would that work?

  8. #8
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA newbie... need help with taking user input from worksheet and creating new table

    That's what I did, the source was changed: example.xlsm

    Contains:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: VBA newbie... need help with taking user input from worksheet and creating new table

    Thanks a lot! I am just learning this VBA stuff, and it's pretty cool. I've pretty much only used Matlab the past 10 years... I didn't even know Excel could be that powerful.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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