+ Reply to Thread
Results 1 to 12 of 12

Dynamic Variables

  1. #1
    Registered User
    Join Date
    03-08-2005
    Posts
    16

    Dynamic Variables

    I'm looking for code that will allow me to load varibles dynamically.

    For instance, if my sheet were the following table:

    Fruit Orange Naval Orange
    Fruit Banana Big Yellow
    Fruit Orange Valencia Orange
    Veg Lettuce Romaine Green
    Veg Avocado Haas Green
    And I wanted to be able to count how many unique items I had in the first column (which would be 2) and then I wanted to write that to info to another column along with the data, how could I do that? This is also assuming that the first column will be different every time I run the macro. If the tables aren't enough I could attach a sheet that show a little more detail in what I'm looking for.

    Thanks.

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Dynamic Variables

    Maybe with an pivot table?
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    03-08-2005
    Posts
    16

    Re: Dynamic Variables

    Thanks for the response.. I'm not sure if that will work. I have code that takes data from a spreadsheet and puts it into Word. In this case, I am wanting to be able to create a list from data that is in a single cell, take that and run it against my sheet, and also count the characteristics. I tried writing this out with the fruit analogy, but it was getting crazy, so let me change it.

    I want to creat a list of radio frequencies from a single cell, "97.9, 99.1, 101.1, 102.3")
    For each frequency in the list i want to record data that is offset in another column, counting how many of each there are.

    Please see the attached file, maybe it will help make this clearer.

    Book1.xlsx

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Dynamic Variables

    I haven't look at your workbook (was working on this when you posted), but see if this will work for you.

    Please Login or Register  to view this content.
    Change the sheet name as needed. The code assumes row-1 is a header (required), counts columns and loops through each using advanced filter to extract unique values and the place a count in the adjacent column.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Dynamic Variables

    I made 2 pivot tables (same data / differant lay out).
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-08-2005
    Posts
    16

    Re: Dynamic Variables

    I appreciate the responses. I'm not real clear on how to extract the information from the pivot tables. The data is being taken from Excel and used to populate a form in Word. As for the loops, I'm going to play with this a bit and see how it works. I will post back tomorrow.

    Thanks again, and Happy Holidays.

  7. #7
    Registered User
    Join Date
    03-08-2005
    Posts
    16

    Re: Dynamic Variables

    One real quick question before I go...

    Is it possible to pass data from a single cell, in this case separated by a comma, into an array instead of using a range of cells?

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Dynamic Variables

    Not quit sure, what your up to.

    Text to column?

    Excel 2007 => data => text to column

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: Dynamic Variables

    Is it possible to pass data from a single cell, in this case separated by a comma, into an array instead of using a range of cells?
    Yes, try this:

    Please Login or Register  to view this content.
    Merry Christmas!!

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  10. #10
    Registered User
    Join Date
    03-08-2005
    Posts
    16

    Re: Dynamic Variables

    Perfect.

    Merry Christmas to you, sir!

  11. #11
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Dynamic Variables

    Is it possible to pass data from a single cell, in this case separated by a comma, into an array instead of using a range of cells?
    This is quite different from the description of your need in your first post. If this was your original need it should have been clearly stated from the start or a new thread started since it is a different question than extracting and counting unique values. I am very happy to help, but now think I've wasted time on a solution you didn't need.

  12. #12
    Registered User
    Join Date
    03-08-2005
    Posts
    16

    Re: Dynamic Variables

    Quote Originally Posted by Palmetto View Post
    This is quite different from the description of your need in your first post. If this was your original need it should have been clearly stated from the start or a new thread started since it is a different question than extracting and counting unique values. I am very happy to help, but now think I've wasted time on a solution you didn't need.
    I apologize for the confusion. Obviously I was still trying to articulate it properly.

+ 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