Skip to main content

Creating Multiple Drop Downs with No Repetition of Values

















Hi Everyone,
I think the picture explains everything whats gonna be in this articles. Yes, Multiple dropdowns with no Repetited Values with only one helper column And lesser and quite easy steps. So here we go.

First we will make some Named Ranges to Capture the Players Pool and Selected Pool. Use Following Non Volatile Dynamic Named Ranges which will Expand and Contract those Pools when Data is added or cut off.


Note:- While Making these Named ranges, you have to select any cell in the first row. This is Important as behaviour of the Named Ranges Depends up on that.

Players (in Column A)
=Sheet1!$A$2:INDEX(Sheet1!$A:$A,MATCH(REPT("Z",100),Sheet1!$A:$A,1))

Selected(in Column D)
=Sheet1!$D$2:INDEX(Sheet1!$D:$D,MATCH(REPT("Z",100),Sheet1!$D:$D,1))

Now in the Next part, Make a Named Range to get an array of Corressponding Row Numbers of Unselected Players in the Players Pool as follows:-

RowArr
=IF(COUNTIF(Selected,Players),FALSE,ROW(Players))

Explanation:-
The COUNTIF(Selected,Players) Part Counts each Player of the Players Pool in Selected Pool and returns an array, having count of Each Player (in Players Pool), of same Size or Dimensions as of Player Pool. If I calculate this Part on Excel Sheet itself then the Returned Array would be (having regard to the Selected Pool that Includes one Player Ie. C Ronaldo) :- 
0
1 <----as C Ronaldo has already been selected, so count comes out to be one.
0
0
0
0
0
0
0

Now If Function(If(Test,Value if True, Value if False)) will parse this Array to one below and in the following way:-
Countif Array Row Array (ROW(Players)) Resultant Array
0 2 2 Reason1
1 3 FALSE Reason2
0 4 4 Reason1
0 5 5 Reason1
0 6 6 Reason1
0 7 7 Reason1
0 8 8 Reason1
0 9 9 Reason1
0 10 10 Reason1

Reasons:-
1. 0 is an equivalent to FALSE. So if function returns the Corressponding Row Number.
2. 1 is an equivalent to TRUE. So if Function returns the Value if TRUE that is False.

This Resultant is stored in the Named Range - RowArr and gets changed whenever a new Player is selected in the Column D or we can say, New Items gets added to the Selected Pool.

Now, We will use a helper column to list unselected Players using Row numbers in the RowArr.
Put this formula in the cell F2 and Drag down untill the last filled cell of Column A to cover all possibilities.
=IFERROR(INDEX($A:$A,SMALL(RowArr,ROW($A1))),"")
The ROW($A1) function(equivalent to 1) has been used as nth Small parameter of Small Function which increments by one as Formula is Dragged down. The Small function returns the 1st, 2nd, 3rd Small value in the RowArr Array and so on, as Formula is Dragged down. This Small value become the Row_Num parameter of the INDEX function and the Unselected Player is returned.

Now making one last Named Range to Cover the Unselected items listed in Helper column.
ItemsLeft:-
=Sheet1!$F$2:INDEX(Sheet1!$F:$F,MATCH("",Sheet1!$F:$F,0)-1)
Now Select D2:D6 Range and click Data Tab ---> Data Validation and write by selecting List option from the Dropdown.
=ItemsLeft

That's how the dropdowns will get activated. Now select the Players from the Dropdowns and you will notice that the Already Selected Players are being deducted from the next cell Dropdown List.

That was all for the Explanation of this technique. However, if you all have any doubt or query then do comment.

Check the attached example file:-


Regards,
Vikas Gautam

Comments

Popular posts from this blog

Automation:- Sending Invitation to Meeting Using Excel VBA

Hello Everyone, In one of the previous post, I wrote about automating Sending Emails using Excel VBA. This time I have come up with a pretty similar code. The code below sends Outlook Meeting Invitations to recipients on one click. here is the Code:- Sub Send_Invite_Auto() Dim olApp As Outlook.Application Dim olApt As AppointmentItem Set olApp = New Outlook.Application 'Creating Outlook Session Set olApt = olApp.CreateItem(olAppointmentItem) 'Creating an Appointment With olApt .Subject = "Enter the subject here." 'Subject .Start = DateAdd("d", 5, Now) 'Enter Date + Time here. .Recipients.Add ("example@gmail.com") 'Recipient Name, Alias, or any other Attribute. .MeetingStatus = olMeeting 'olAppointmentItem with Meeting status olMeeting 'becom

Highlighting Duplicates across multiple sheets

Hi One and All, This time I have come up with some conditional formatting stuff. The aim is to highlight the duplicates across multiple sheets and with in the sheet as well. Assumptions:- 1. I am assuming that sheet names goes on like sheet1, sheet2, sheet3.... 2. The Target Column No. is same in all the sheets. I mean, as in the attached example, its Column A which is being targeted in both sheets.

Making Password Protected PDFs using Excel Vba and PDFtk Tool

Hi Everyone, This time, I have come up a VBA Code to generate Password protected PDFs using Excel. Actually, Excel Vba has .ExportAsFixedFormat Method to generate PDFs but this hasn't any Parameter which takes password to protect the PDFs. So I have used PDFtk Tool which provide Command Line Interface to make PDFs protected using Password. Actually, You can do various things using PDFtk Tool command line varying from creating, merging, Protecting and many other. So Download the PDFtk Tool from the following link:- Download PDFtk Tookit Here are the Steps:- 1. Install the PDFtk Toolkit. 2. Use the following code to Print or Export the Activesheet with a password.