Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Code for filling cells in all possible combinations and distributions

0

Hello to all. I need VBA macro code for the following problem.

                1.  There are nine english alphabets ( r,s,t,u,v,w,x,y,z)

                2.  They should be used to fill the cells in 12 columns A,B,C,D,E,F,G,H,I,J,K,L  in each row.

                3.  In a row  an alphabet can appear only once. But all the nine alphabets should be in a row

                4.  A cell may contain all the nine alphabets,or 8alphabets,7,6,5,4,3,2,or 1alphabet.

                     (Order does not matter. r,s,t  -t,s,r, -s,r,t-s,t,r all are equal) . A cell  can be  blank also.

I need a code to fill the cells in all possible combinations and distributions. For example If I want to find a row in which column A is blank, --6 alphabets r,u,z,t,,x,w in B,-- C,D, Blank,- -'s' in E,  -'v'  'y'in F,--G,H,I,J,K,L,Blanks--     one such row should be there.

As I do not know permutations and combinations, I do not know how to write the code. But I can use a witten code.  Will some one help me?

Answer
Discuss

Discussion

Hi

I assume you are referring to those 9 English letters (not alphabets - which comprise many letters, e.g character sets like the English, Spanish or Cyrillic alphabets) but what are you trying to do with the very many possible combinations in the real world?
John_Ru (rep: 6142) Jun 5, '21 at 12:02 pm
Thank you very much for the correction. I am referring to letters only.If the letters represent nine planets like Jupiter,saturn, venus etc,and the twelve cells represent 12 zodiac signs,I want to find out all possible planetary distributions in the zodiac signs.Just being curious. Thanks once again
Slowlearner Jun 6, '21 at 10:50 pm
Seems you're referring to astrology. If (despite astronomy) each of 9 planets can be in one of the 12 signs, then I reckon there are 5,159,780,352 possible combinations. Sorry but I've no interest in coding for that many results nor in perpetrating astrology. Good luck! 
John_Ru (rep: 6142) Jun 9, '21 at 5:00 am
Add to Discussion



Answer the Question

You must create an account to use the forum. Create an Account or Login