Excel VBA - Set value of multi column combobox based on second column - excel

I have a multicolumn combobox
First column is a number ID and second one a string, like this
ID
STRING
1
value 1
2
value 2
What I want is to set the selected value of the combobox based on the value of the second column
Lets say I click a listbox that contains the string "value 1", then I want to combobox to be selected on that.
Using ComboBox.value does not work because needs to be based on the first column
Appreciate any help

Related

Is there an "if" function in Excel for auto-filling a user ID number based on a separate user ID number that's already been found?

I am trying to auto-fill a person's user ID number based on repeat information in the table. I have an excel sheet with people that have two user ID #'s so I would like to auto-fill the second number based on the first. i.e. I have 3 columns. Column 1 = name, column 2 = user ID #1 and column 3 = user ID #2. So if Gerald = 3 and 5, how do I get excel to auto-fill the user ID #2 as 5 every time column 2 = 3. It's the same data repeated over and over. As in I have multiple Gerald entries and I want it to auto-fill everytime he comes up based on his first user ID#. It's all in the same sheet so I don't have to switch tabs or anything.
I've tried going through "if" functions but I don't know how to make the right formula.
You can use the VLOOKUP function in Excel to achieve what you're trying to do.
The VLOOKUP function searches for a value in the first column of a table and returns the value in the same row from a specified column. In your case, you want to search for the first user ID # in column 2, find the corresponding name in column 1, and return the second user ID # in column 3.
try this formula
=VLOOKUP(B2,A2:C10,3,FALSE)
This formula assumes that your data starts in cell A2 and goes until cell C10. The first argument (B2) is the value you're searching for, which is the first user ID # in column 2. The second argument (A2:C10) is the range that contains the data you want to search in. The third argument (3) is the column number from the range that you want to return a value from. In this case, it's the third column, which contains the second user ID #. The fourth argument (FALSE) specifies that the VLOOKUP function should perform an exact match search.
You can copy this formula down to the rest of the cells in column 3 to auto-fill the second user ID # based on the first.
This formula assumes that there are no duplicates in the first user ID # column (column 2). If there are duplicates, the formula will only return the first match it finds.

Update column based on dropdown selection

I have 2 sheets on Google Sheets. In the first sheet I have multiple columns which are repeated, where for every 2 columns, the first one is the product name, and the second one is the quantity sold for each of the products. What I will do on this sheet is select the product that the customer bought on the dropdown, and insert the quantity bought in the next cell. I need multiple columns as some customer buy multiple product types at one time.
Then in the second sheet, I want to tabulate the quantity for each products which is predefined in the header. This is meant to be automated.
Sheet 1
Sheet 2
Below is the link to a sample file.
https://docs.google.com/spreadsheets/d/151D6-QE_ePOyPEeMfMO9GSOQrFVQ5AbsagOaQUm_2eU/edit?usp=sharing
Can anyone help me with getting the qty populated on the matrix table based on the qty input next to the dropdown list? The closest that I got is using below formula, but the quantity is always based on the first dropdown qty only.
=IF(SUMPRODUCT(--(C$2 = {product!$C4,product!$E4,product!$G4,product!$I4,product!$K4})) > 0, -1*product!$D4,"")
I guess a good starting point would be how to get the address from Sheet1 that have the value corresponding to the table header in Sheet2.
Heres how I would do it
I'd use an index with match the "Ref ID" Row and the "product" Column (offset by +1 for the value)
Then to make the results dynamic to the "Ref ID" I put an indirect range reference matching the "Ref ID". I then wrapped it in an IFERROR then 0 if it doesnt have a product within a Ref ID.
Hope this makes sense, I'm sure the example below will make more sense than me :)
Code to go in C4
=IFERROR(-index(Sheet1!$1:$607,match($A4,Sheet1!$A:$A,0),match(C$3,indirect("Sheet1!$"&match($A4,Sheet1!$A:$A,0)&":$"&match($A4,Sheet1!$A:$A,0)),0)+1),0)
Example on Sheet 2:
https://docs.google.com/spreadsheets/d/1eeonWF8gcvQdDrTlydmHiMzr9MZpRDAkX_fZBX95yaI/edit?usp=sharing

show only values if checkbox value is true

I have data list in column B1:B4 as below
Section_A
Section_B
Section_C
Section_D
in-front of these values in column A1:A4 I have 4 check boxes placed.(form control type not active X).I want generate only clicked values to column C.Example:After first check box and third check box clicked Show Section_A and Section_C.(In column C need this result without blank cell between Section_A and Section_C.
You can use LARGE method for which you would need to add one more column.
1st: link your checkbox with cells in column A so that respective cell will give TRUE or FALSE when the checkbox is ticked or unticked respectively.
2nd: Move your column B data into column C and in front of each cell in column A, Assign weight in column B(You can Hide this column If you don't want this to be visible).
3rd: Use Large Function in column D as shown in Below SS.
change the color of cells in column A to white and Hide Column B, it would look something like this.
and your work is done.

Equivalent of SELECT FROM WHERE on Excel

I have a dataset on an Excel table in which each line has an Id and several other columns.
in some others sheets I need to select some columns depending on the given id.
I am using Excel 2016, so I've tried the "dget" function but it seems not to be the best solution.
For the dataset it's close to this:
id Name birth date gendre
1 Sara 10/05/1997 F
2 Edward 01/08/1994 M
3 Anna 06/10/1993 F
and for getting data I use
=DGET(Table1[#All];Table2[[#Headers];[Name]];A1:A2)
in each column (A1:A2 here is for id and 2)
id Name salary
2 Edward 5000
and then I add some new columns that I don't want them to be in the first dataset.
This solution works only for the first row since it requires a the Criteria (last field in DGET function) to be a range, the official definition:
Criteria Required. The range of cells that contains the conditions that you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
Starting from the second row the Criteria is not a range anymore it is like "A1;A3" (for the 1st row "A1:A2")
Is there any other solution or alternative to do so?
Select a cell in the Table, click Insert>PivotTable, then drag the ID, Name, BirthDate, and Gender fields into the ROWS area. Then add a Slicer on ID, Name, and Salary by clicking in the PivotTable and selecting Insert Slicer. Then choose the ID/Name/Salary values you want. To make multiple selections, hold down Ctrl or click the MultiSelect button of the Slicer.

onclick copy value to next available cell in column

I have a dropdown list of items which are in a table with corresponding values. Below the dropdown list I have a VLookup to find the value of the item. I need to keep a count of the total value that these are worth. Once the dropdown list is selected I need the value of the VLookup copied and pasted into the next available cell in the column. Complicating this is that each column corresponds to a different person who can have items added to their total in any order.
When column B has an item selected I need to copy the value to the bottom of column B, similarly for column C, etc.
I know I need to do use onclick function but everything I have seen copies onto the next available row without keeping column discipline. Would I need to name each column and onclick function separately or is there a neater solution?

Resources