Microsoft Excel VBA - drop down list auto populates multiple fields - excel

I have an Excel workbook where on one sheet I have two columns of data.
For example:
ColumnA ColumnB
1000 DescriptionFor1000
1001 DescriptionFor1001
1002 DescriptionFor1002
1003 DescriptionFor1003
...
On another sheet, I have one column set with Data Validation so that each cell value must equal a value from ColumnA above (ex. 1000 or 1001 or 1002 etc).
When the user selects a value from the drop down list of ColumnA values, I would like the column next to it be autopopulated with ColumnB value from above.
For example, if the user selected 1001, the cell right next to it would automatically fill with "DescriptionFor1001"
I do not have code here because there is none to display (all controlled through Excel so far). Is there a way to do this? I do not mind writing VBA code if need be.

A VLOOKUP formula should do the trick. Let's assume the dropdown in in cell A1, and the data for the dropdown is in Sheet2!A1:B10, the formula would be:
=VLOOKUP(A1,Sheet2!A1:B10,2,FALSE)

Related

Cumulative Amounts of Dupe-only Items in a Resultant Sheet

Sheet 1 goes like this:
Sheet 2 should be like this:
ITEMS QUANTITIES
APPLE 4
GUAVA 2
Sorry for writing the spreadsheet in here, as I'm not allowed to include more than 1 image yet.
Suppose you have the following named ranges:
ITEMS being the data in ITEMS column on your Sheet1;
QUANTITY being the data in QUANTITY column on your Sheet1.
Enter the following formula in Cell D2 on your Sheet2:
=IFERROR(INDEX(ITEMS,MATCH(0,COUNTIF($D$1:D1,ITEMS),0)),"")
Please note it is an array formula which requires you to press Ctrl+Shift+Enter upon finishing the formula in the formula bar.
Drag it down until there is no more items showing up.
Then you can enter the following formula in Cell E2 on your Sheet2 and drag it down:
=SUMIF(ITEMS,D2,QUANTITY)
As you can see from the above screenshot, there may be some empty cells in Column D as I used IFERROR to return blank cells if there is no more distinct item. The corresponding quantity will be 0 consequently. You can choose to delete them or hide them on your worksheet.
By the way I am not sure why Pivot Table is out of the picture as it is actually a faster and easier approach than formula and you do not have to worry about the blank cells returned by the formula if the number of unique items is uncertain. All you need to do is to highlight the source data, insert a pivot table, and put the ITEM in Rows and QUANTITY in Values field.
EDIT: Update to also extract unique distinct values:
Enter this formula in cell A2 of Sheet2:
=IFERROR(LOOKUP(2,1/(COUNTIF($A$1:A1,Sheet1!$A$2:$A$300)=0),Sheet1!$A$2:$A$300), "")
Change 300 to the actual last row of your data and copy that formula down until it returns empty cells.
Then just use a regular SUMIF in cell B2 of Sheet2:
=SUMIF(Sheet1!A2:A300, A2, Sheet1!B2:B10)
Then, type whatever fruit you're looking for incell A2 of Sheet2. Continue like this in the following rows for all the fruits you need.

I am using vlookup across 2 spreadsheets. The formula appears to be correct, but the value is not returning, only the formula displays

I am using 2 spreadsheets. Sheet1 -Return Codes needs the values from Sheet 2- GL Interfaces. I am trying to match with column 1 on sheet 1 to sheet 2 in order to bring back the correct Name associated with an application ID.
The formula displays in the cell instead of the value replacing the formula:
=VLOOKUP(A2,'GL Interfaces'!A2:F61,2,False). What is wrong with my formula for this simple lookup?
I click in the column where I want the value to return to.
Click Formula | select Vlookup.
Click on A2 (the column with the application numbers) on sheet 1
Go to second sheet and highlight array that I want to be searched.
Put in 2 as a column with the Names (col index num) that I want to be searched on the second sheet
Enter False for the last entry (Range_Lookup)
Enter and only the formal displays in the cell I want a Name to appear.
What am I doing wrong?
=VLOOKUP(A2, 'GL Interfaces'!A2:F61, 2, false)
is a valid formula. make sure that the first column of the 2nd argument of vlookup is the one that contains the value from the first argument of vlookup. in other words: A2 needs to be found in A column of sheet GL Interfaces and if there is a row with a match, then return value from B column of GL Interfaces sheet

Finding unique values between 2 Excel columns

I have two simple columns in Excel below
ID ID1
123 123
124 125
125 126
126
I was able to use the conditional formatting in excel as follow:
1. Highlight the 2 columns
2. Click on the conditional formatting
3. New rule
4. Select format only unique or duplicate values
5. Select unique under format all:
6. Select Format and click ok.
I can see that the steps above shows the highlighted value which is 124.
My question is, how can I filter out that 124 value from such a small sample above?
I have a columnA that has 50k records and columnB that has 48k records. I want to see or filter out the 2k records from columnA.
Here's one approach using match and a filter.
Enter =MATCH(A1,B:B,) in column c add a filter to row 1 and filter for column C values that are #N/A the values in column A which say #N/A in column C are not in column B.
An alternative approach would be to move the column B under Column A and use COLUMN b to define the source ID, ID1... and then use a pivot table to show you both sets and what could be missing from each...
Notice how 5 is not IN ID while 13 is in ID but not in ID1.
also notice that duplicates on Row 5 show up as well.
One way of doing this (kind of manual) is to find the values which are duplicates (the ones that are highlighted). Then select both the columns and all the data.
Then go to: Home > Editing group> Sort & Filter > Filter
There should be small, down arrows on the column headers. Then you can un-check the duplicates.
EDIT
Thanks to xQbert for pointing out my mistake. Here is a way to solve this:
If possible, you can move the second column to another worksheet. Now use the following formula in a column next to the first column:
=COUNTIF(Sheet2!A2:A5,Sheet1!A2:A5)
Just change the cells to the ones for your table. The first parameter is the second column (which you should have put in the new sheet). The second parameter is the first column which will be highlighted. This will put a '1' next to each value which is duplicated.
Then you can use conditional formatting to highlight the cells with a '1' next to them using this formula in the "New Rule":
=B2=1 That is the cell number of the first cell in the first column. It should be highlighted to the colour you set it to. To copy the formatting to the rest of the cells, click on the first cell B1. Then go Home > Format Painter. Drag the formatting to the entire column.
You can then use the filter to show only the cells with "No Fill"
You will have to do the same for the data in the new sheet.
This was a very 'hacky' solution but it's what is possible.

How do I automatically update cells to match values from another sheet when one cell is changed using data validation?

I have a list of items on Sheet 1 with the names of each item in column A and then further information in the subsequent 5 columns.
On Sheet 2, in each of the cells of column A, I have set it so that I can pick any item from a dropdown list using data validation. I want the subsequent cells in the row to automatically assume the value of the respective cells in Sheet 1.
So if in Sheet 2, Cell A1 I select Item 3 (which is in Cell A3 on Sheet one), I want Cell B1 on Sheet 2 to have the same value as Cell B3 on Sheet 1.
I could get the result I wanted by using =IF($A3='Sheet1'!A3,'Sheet1'!B3,) and then adding each possible item but that seems really long winded and would require adding to the formula every time I added an item.
Any idea if there is a way of doing this? Sorry if my explanation is a bit confusing. My excel knowledge is not great!!
Thanks in advance
Use the Vlookup function
Next to your data validation cell, enter (assuming the first sheet called Sheet1):
=Vlookup(a1,Sheet1!a:f,2,0)
This will return the data that match for the 2nd column. For the 3rd use:
=Vlookup(a1,Sheet1!a:f,3,0)
And so on..

Referencing current cell for compare across sheets

I'm trying to compare binary values between two sheets in Excel. Here's a quick snapshot of what the data might look like for row 1, columns A-D on the two sheets.
A B C D
1 1 1 1 1 <--- Sheet 1
A B C D
1 1 1 0 0 <--- Sheet 2
What I would like to do is Conditionally Format sheet 2. I'm only concerned about the cells where the values are not the same, so in the example above cells C1 and D1 on Sheet 2 do not match the values on Sheet 1, so I want to either change the font or background. At this point I don't care. If I were just comparing these 4 cells I could do this easily enough. But I've actually got 160 rows and about 1000 columns of binary data, so I don't want to condition each cell individually. What I can't figure out is how to conditionally format the entire sheet using a formula that references the current cell vs the current cell on the other sheet.
For excel 2010:
Select the area on sheet 2 you want to compare
Select conditional formatting under the "home" ribbon, then "new rule"
Select "use a formula to determine which cells to format"
Type the following, but replace "A1" with the top left cell in your selection range, and replace the sheet names with your sheet names
=IF(Sheet1!A1=Sheet2!A1,FALSE,TRUE)
Select your desired format
Hit "OK" on both dialogs
In general, you could use a comparison utility like BeyondCompare. Ensure each sheet is saved into its own file, then throw them at the utility.

Resources