+ Reply to Thread
Results 1 to 4 of 4

Sample VBA array

  1. #1
    Forum Contributor
    Join Date
    01-28-2013
    Location
    sweden
    MS-Off Ver
    Excel 2010
    Posts
    108

    Sample VBA array

    Hi,

    I have an Array like this

    Please Login or Register  to view this content.
    I have my elements in the first dimension of Array and probability in second dimension. I would like to take one sample from the first dimension with corresponding probabilities in second column.

    In this example I will have 10% of sample any value between A to J. Probability will vary in real example, so fact with 10% for each item cannot be used.

    Appreciate all help, as always

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Sample VBA array

    Hi,
    What is the question here?
    Do you need to fill your array with different probabilities? Or ... ?

  3. #3
    Forum Contributor
    Join Date
    01-28-2013
    Location
    sweden
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Sample VBA array

    Hi,

    Sorry for being unclear.

    What I really want is a function that returns sample from my testArr.

    Functions argument should be how many sample I want and one 2-dimensional Array with Items in first dimension and probabilities in 2nd dimension (my testArr)

    Function sample(n as long, arr() as variant) as variant

    sample(10, testArr) will return 10 items from first dimension in testArr where A, B, ..., J all of 10% chance of be selected on each sample.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,465

    Re: Sample VBA array

    Not really clear though...
    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: 16
    Last Post: 05-11-2016, 08:24 PM
  2. [SOLVED] sample search
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-24-2013, 12:25 AM
  3. Array Formula Not Working - Sample Attached
    By Excel"*" in forum Excel General
    Replies: 4
    Last Post: 08-13-2012, 04:48 PM
  4. sample
    By ALex60 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-04-2008, 09:39 PM
  5. Sample
    By David in forum Excel General
    Replies: 3
    Last Post: 08-24-2005, 05:05 PM
  6. Need Sample VBA Code
    By Bill Sturdevant in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-26-2005, 07:06 PM

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