+ Reply to Thread
Results 1 to 16 of 16

Excel Random Text in column from a set of options without duplicates

  1. #1
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Excel Random Text in column from a set of options without duplicates

    Hi

    I am searching out a way to resolve a problem in excel using vba. I tried it using formula, but, could arrive at a solution.

    Conditions required for filling column B.

    1. Column B needs to be filled up using values given in cells from Col G to Col K.
    2. From Col G to Col K have values with prefix starting from P,C,M.B,Z, Each column may have duplicate values.

    Required
    Col B needs to be filled up using these set of values designated for each row (given in Col G to Col K), so that Col B doesn't have any common / duplicate values.

    The work out which has been done till now is attached for reference, sheet - With formula.

    Kindly help me out on this......Please.


    Regards
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Excel Random Text in column from a set of options without duplicates

    Try:
    Please Login or Register  to view this content.
    This code is just like pressing F9 and checking if there were duplicates in column B - if yes pressing F9 again and again until no duplicates were observed.
    As a matter of fact duplicates are checked after each random selection, because there is no point to draw next value (in next row) if current one is already a duplicate :-)
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Thanks for the prompt reply, the solution is perfectly working for the range mentioned. However, it becomes an endless loop when I am working with rows close to 30.

    For more convenience, I am attaching a sample sheet which I would be using for my purpose. In this attached sheet, the code was ran for an approximately 30 minutes, and eventually I had to stop this code to arrive a solution for these number of rows.

    This is actually a timetable for a week, where the faculty codes are to be placed in columns, so that there are no duplicates in any column.

    https://app.box.com/s/awfq4q8xgfb9lkqoj4x5bv0v2kskqu77

    I was wondering, how this could be accomplished when there are 30 rows and 21 columns are to be checked for proper ordering (from the options available) with no duplicate values in any column. Yes, “X” or “Hdy” can be an exception. The check that each prefix count (P,C,B,or Z) has to be a fixed number for any batch with-in a week , which would also be given from Col AX to Col BE.

    Requesting for inputs on this.

    Regards
    Attached Files Attached Files
    Last edited by sanits591; 03-11-2017 at 06:57 AM. Reason: Attachment added

  4. #4
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Hi Kaper

    Kindly help on this.

    Regards

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Excel Random Text in column from a set of options without duplicates

    There is no chance to do it as you described.
    In BS3:BV3 you have the same values (empty cells) as in BS21:BV21 and some further rows.
    So empty cells will always repeat.

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Excel Random Text in column from a set of options without duplicates

    PS. Data is very heavily restricting possible solutions.
    For instance RM-05E shall be given P2 and RM-15E shall be C6 because there is no other rows with P2 or C6 available.
    RM-11E shall be either C7 or Z4 - one of these 2 will always remain unselected.
    If we include this information, RM-16H shall be B6 (the only place where B6 can be used), then RM-22E shall be C8 and RM-09E shall be B5
    then RM-20H and RM-13E shall be asssigned (in any sequence) C2 and P7.
    etc.
    See sheet Arkusz1
    It is reasonably easy with functions and manual selection, but to have it fully automatic with macro is (at least for me) not so easy.

    And I am not surprised totally random solution searc gave no effect after half an hour. possible assignments number is 4^19 while number of acceptable solutions is probably just few dozens. so we have probability around one billionth :-(
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Thankyou Kaper for responding and performing such an analysis on this.

    Till now, we have been preparing such a timetable manually (for around 60 batches, under different groups), and it takes a lot of pain from various inputs to prepare this and consumes almost a day. That is why we look for automation of this timetable.

    Yes, it is very well taken the probability is very low to arrive at some possible solutions. Instead of doing it manually, can we put some constraints on this, to reduce the denominator of total permutations of arranging Faculty code for any column? For example:

    1. As there are 3 classes for a batch (1,2,3), and faculty codes with prefixes are (P,C,B,Z), can we fix up like, “P” code shall be taking 1st class, 2nd class shall be booked for “C” Code or some other?, depending upon our choice order in some matrix (in tabular form, Class Preference order Matrix) i.e. from Column BF to BH.

    2. A helper column has been introduced which is about the count of each faculty code allocated to different batches. Probably this shall help in shuffling of Faculty Codes (P1,P2….. etc.) to some extent, i.e. more the count in column (BJ, extended upto Col BM), implies that code can be placed in more number of batches.

    3. In a row, for a week, the maximum number of lectures possible is 21 for any batch, the different allocation of number of faculty codes for a week can be obtained from (AF to AI).

    4. Adding a "Hdy" "Holiday" for any day for any class may not put any faculty code on this, which shall further minimize the denominator.

    Seeing this much of permutations, yes, it is very much essential to reduce denominator first, then calculate the options available.

    Regards
    Attached Files Attached Files
    Last edited by sanits591; 03-13-2017 at 01:00 PM. Reason: Point no. 4

  8. #8
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Kindly help me on this, as calculating these choices is beyond my scope with the currently learnt skills.

    An excel file is attached with these columns.

    Regards

  9. #9
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Hi

    Requesting assistance on the above....


    Regards

  10. #10
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Please help me out, sincerely looking for a solution on the same.

    Regards

  11. #11
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Excel Random Text in column from a set of options without duplicates

    I do think it is rather time consuming, so at the momentI will not continue in this thread.
    Anaybody willing to participate in looking for solution is kindly welcome to join in.
    Other idea could be to publish the question in http://www.excelforum.com/commercial-services/ subforum

  12. #12
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Thanks! Kaper for suggestions. However, in the last few days, something sorted out to some extent on the similar subject. In line with this, i modified your code, but, this code is stopping not at a desirable point.

    Could anyone help me out on this!


    Please Login or Register  to view this content.

  13. #13
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Excel Random Text in column from a set of options without duplicates

    1) Mod is a not good name - there is operator mod in VBA, so to avoid confusion fo user and for VBA compliator/interpreter use different sub name (like myMod, etc.)
    2) Rank for P&i (which for instance for P3 is empty ) out of Range("P" & i & ":" & "S" & i) (most are empty, and S&i seems to be related to next day

  14. #14
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Thanks Kaper!

    The Current sheet which has been used for practice to get the similar results as discussed in previous posts is attached for reference.

    The code mentioned just above is related with this file ("Sheet1") only.

    Yes, i shall not name any subroutine with "Mod" or any VBA functon.

    The code which becomes problematic in giving the uniqueness in a column. Kindly help!.

  15. #15
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Yes, if i run the below mentioned code, it works perfectly for a single column and provided the result with unique faculty codes in col E, with in very short time. But, as soon as i introduce a " j " variable for columns, this doesn't lead to desired results.

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    05-27-2009
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Excel Random Text in column from a set of options without duplicates

    Thankyou Kaper for your guidance! Eventually i reached to a solution, as given below:

    Please Login or Register  to view this content.

    Regards

+ 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] Random sample in excel WITHOUT duplicates.
    By rshukla in forum Excel General
    Replies: 9
    Last Post: 08-09-2017, 09:54 PM
  2. Generate Random Text, but to preserve the matching Column A & Column B
    By Andy8 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-28-2016, 03:24 AM
  3. [SOLVED] Code for random spaces for text to column in VBA
    By ndemetres in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2014, 04:38 PM
  4. [SOLVED] a formula that copies and pastes different text options in the same column
    By nicki_rae22 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-01-2013, 04:50 AM
  5. Replies: 21
    Last Post: 08-13-2012, 01:52 PM
  6. extracting text string with 2 options @ end & limited options
    By ChristianR in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 10-24-2010, 06:51 AM
  7. Can you change the Text Import Wizard column options
    By SteveB in forum Excel General
    Replies: 3
    Last Post: 07-28-2006, 02:35 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