Check for duplicate value among 10 combox boxes when summit excel vba - excel

I have 10 comboboxes on my userform that share 10 same selections, and I would like to check for duplicated value before summit.
As far as I can imagine, there are two ways to get the result, the first one is to check for same value among these ten boxes when summit by using message box OR to hide the selections from other comboboxes once the option is being selected by any one of the boxes.
Since I am new to vba, I am having a hard to grasp this idea in to code, please help.Userform with 10 comboboxes that share the same selections

I think your second idea is the best, because it prevents the unwanted behavior instead of correcting it.
You can either build a responsive sql which filters out the already selected values, or you could create 10 queries, one for each combobox.
Start by creating a table with values you want to have for your selection.
Make a query like this: (Combobox1) SELECT value FROM Table;
This is the input query for your first combobox.
Create a second query (Combobox2) based on the first query. SELECT value FROM Query1 WHERE value <> Forms!formname!Combobox1
This will be the input query for your second combobox.
Now create a third query based on the second like: SELECT value FROM Query2 WHERE value <> Forms!formname!Combobox2; Which will be the input for your third combobox.
Keep on doing this untill you have a query for each combobox.

Related

Generate comboboxes depending on number inserted in first combobox

I'm doing an userform where in one of the fields (lets say its combobox1) the user is asked for the number of failures, and for each failure he has to put the type of failure, number of part and in another field the type of rework (3 fields to fill for each failure). And what I would like to know if that if it's possible to generate comboboxes depending on the number of failures made. For example: if the user puts 3 in the field of failures, 9 comboboxes should appear and so on.
I also think that maybe another way would be to have the standards 3 comboboxes and clear the fields each time the user press a button and a counter appears indicating which failure description he is filling, but I would also like to know how this could integrate into the whole userform, which already has a "submit" button.
Maybe there could be another reasoning for this, and I would greatly appreciate any help.
I don't really have much experience using dynamically created tabstrips, but they may be helpful with creating the layout you're describing. I would recommended in the base userform, include a tabstrip with a single tab and the 3 comboboxes/textboxes that are needed for a single failure. (You could keep it invisible until after "combobox1" has a value, if desired) Then use the number from the combobox to dynamically create the additional tabs on the tabstrip:
Private Sub ComboBox_Change()
'To remove previous tabs if combobox changed
For i = 1 To TabStrip1.Tabs.Count - 1
TabStrip1.Tabs.Remove(i)
Next i
'Adding additional tabs to tabstrip
For i = 1 To ComboBox.Value - 1
TabStrip1.Tabs.Add
Next i
End Sub
The tab currently selected can be identified by using the TabStrip1.Value property. I think the change event is queued by the TabStrip1.Value changing.
You will have to manually clear out any values when the tab strip changes (or fill back in values they previously filled out but want to view again).
However, since you'd be determining which tab you're on by "index" (the .value property) you could create a 2d array (redim it to correct rows/columns based off combobox1's value) and use the tab "index" to store combobox values and retrieve existing values for when the user switches back to an existing tab.
And maybe consider "locking" the combobox1 so the value can't be changed by accident. This could be accomplished by having a variable initialized to, maybe -1, which gets set to the combobox value after they've started adding infor to the incidents. Or don't remove any tabstrip tabs, only add if the number is greater than the existing count. (If you want them to put in whatever value they'd like, maybe consider using a textbox?)

how to limit excel column to limited number of words

I'm working with VBA, Excel. I have some set of words, say 10.
When I choose a particular column, then what ever I enter in that coulmn must be from those selected set of words.
It's like dropdown list but I really donot want to use dropdown list. This must be done to a column(or set of cells).
Hey you should be able to do it just like dropdown list but without in-cell dropdown option marked. Its an option that is automaticly marked when you validate column by list in validation form.

Excel pivot table search filter with and / or

I am trying to filter a field in a pivot table so that it only shows some values.
I have a field which is product code and I want to only show the product codes that are H01, P07, F04, L43, ... and the list continues. For the moment, I have to click the little arrow next to the field, do a search on the code and then click on the checkbox add current filter to selection and hit ok. I have to do this 20 times for the 20 different product codes.
Is there a way to enter in the search box immediately H01, P07, F04, L43, ... just once and then hit ok and I ll see all the product codes immediately?
Thanks,
John.
You can loop through pivot items and select the ones that match your criteria using VBA as suggested here:
Looping through report filters to change visibility doesn't work
The only issue I've had with this sort of approach is that you cannot deselect the only selected item, so if you are going to be deselecting then you should make sure to select particular items as well.

jqgrid click select all, but not all of them selected

I use jqgrid with multiple selection. When i clicked select all for a multiple rows data, not all of them automatically checked. What was wrong with this?
If my grid has only one row, select all works.
The root reasons is that the there are duplicated row id in json data. Following example show that there exists the duplicated row id for 2 and 3. One the first of the duplicated row id will be selected when select all.
{"page":"1","total":"1","records":"10","rows":[
{"id":"10","cell":["firstaceha","Evebdfg","5","10","2000-01-30","12:30","notesss"]},{"id":"9","cell":["firstaceh","Evebdfg","7","9","2000-01-30","12:30","notesss"]},
{"id":"2","cell":["firsta","Eve","1","2","2000-01-30","12:30","notesss"]},{"id":"2","cell":["firsta","Eve","9","2","2000-01-30","12:31","notesss"]},
{"id":"3","cell":["firsta","Eveb","6","3","2000-01-30","12:30a","notesss"]},{"id":"2","cell":["firsta","Eve","8","2","2000-01-30","12:30ab","notesss"]},
{"id":"2","cell":["firsta","Eve","2","2","2000-01-30","12:30a","notesss"]},{"id":"3","cell":["firsta","Eveb","10","3","2000-01-30","12:30aa","notesss"]},
{"id":"3","cell":["firsta","Eveb","4","3","2000-01-30","12:30","notesss"]},{"id":"1","cell":["first","Eve","3","1","2000-01-30","12:30","notesss"]}]}

Dynamic Filters in Excel

I'm using Office 2013, and working on a worksheet in Excel.
My question is, is there a way to create a dynamic filter in Excel?
To explain in more detail, I have a dynamic worksheet, where upon opening the user will get a few drop-down options. After the user has selected one option from each of the drop-downs, the worksheet will display a table of data based on the user's inputs. The user can change their selections from the drop-downs after the table has been displayed, and can also clear their selections. If they clear their selection, the table will disappear.
Now, the first column in the result Table will contain Text values, but can also contain blanks. These values or blanks are all decided based on the user's selections in the previously mentioned drop-downs, which are displayed permanently to the left of the table. I want to add a filter to this first column of the result table (and to the rest of the table with it) such that only the non blank cells are displayed in the table every time the drop-downs are changed.
As I understand your need correct, I can give you this solution:
For getting a better result make your range to Table.
Select Power View from Insert items;
A sheet Power View 1 will added to your workbook;
From right pane select Table1 and its fields;
From Filter pane select as you want for filtering.

Resources