+ Reply to Thread
Results 1 to 3 of 3

Random distribution of given number and given Probabilit - PLUS replace! :-)

  1. #1
    Registered User
    Join Date
    11-28-2017
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    21

    Red face Random distribution of given number and given Probabilit - PLUS replace! :-)

    Hey guys.

    I have an excel sheet for enabling quick coloration based on the cells content and i recieved so much help from this forum with that.
    Now i need to add a functionality to it:

    I have a list of positions and RAL codes like the one in sheet "random_list" with random RAL codes distributed by a given probability (in this case 33%).
    Now my problem is that i need to replace the content of all cells in sheets "replacement" containing a given char (lets say "A") in my sheet with the RAL code, just as the list is written.

    Now i assume it's possible to ask Excel to replace the first occurance with the first position in the list, the second with the second an so forth. I'm still thinking about the best approach for the positions though.
    In this example, one position is four RAL codes and another one is 44 RAL codes.
    I think i need to select the area containing "position 3" and then run a macro which will ask me what area i have selected (3) and then verify that the amount of cells containing "A" in that selection matches the amount of RAL codes in the list. If if does the replacing should commence.
    I don't have a clue on how to write the replacement sub though.. :-/

    I've already replaced "pos1" in my example to show what i need as a result.

    https://www.dropbox.com/s/a9l1p4h3tb...ook2.xlsx?dl=0

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Random distribution of given number and given Probabilit - PLUS replace! :-)

    Hi there,

    I think this does as you've described above:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Registered User
    Join Date
    11-28-2017
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    21

    Re: Random distribution of given number and given Probabilit - PLUS replace! :-)

    This is SO awesome WidoBiyDixon!
    Thank you so much, you actually nailed it. <3

    All i had to do was to turn off screenupdating before the loop to save some valuable seconds. Some of my sheets can be large.

+ 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. [SOLVED] Generating a Random Number that follows the Bessely Distribution
    By ancog in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-08-2019, 06:45 PM
  2. Replies: 3
    Last Post: 12-11-2016, 05:20 PM
  3. [SOLVED] Random Number Generated from Truncated Distribution
    By love_sick7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-24-2014, 10:57 AM
  4. Replies: 3
    Last Post: 08-05-2012, 05:47 PM
  5. [SOLVED] Compare columns, replace matching number with reference number and fill down random amount
    By datadigger in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-04-2012, 10:53 PM
  6. Replies: 6
    Last Post: 12-05-2008, 02:31 PM
  7. Log distribution random number generator
    By cameron mcintyre in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2005, 07:05 AM

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