Getting same value with different options from drop-down list. For Google Sheets

YaziR

New Member
Joined
May 1, 2022
Messages
13
Office Version
  1. 2019
Platform
  1. Windows
I'm currently working on a project where I need to create a drop-down list which should automatically populate the tables below. I'll straight away jump to the example for better understanding.
So the Sheet looks like this.
So the data is like
Ex.jpg

I think the table is self-explanatory. I have the data for each fruit that goes to which plate. So if I choose plate 5 from the dropdown list, I should get Apple, Orange, Pineapple, Mango and Berries in the table below.
Please help me with how to achieve this. Thank you in advance.
 
Last edited by a moderator:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Welcome to Mr. Excel.

Please clarify how you want the results presented. With 365 it's rather easy.
With 2019 you might consider:

temporary.xlsm
ABCDE
1ApplePlate 1, Plate 3, Plate 5Apple
2OrangePlate 1, Plate 2, Plate 4, Plate 5OrangePlate 5
3PineapplePlate 5Pineapple
4MangoPlate 1, Plate 4, Plate 5Mango
5BerriesPlate 5Berries
6BananaPlate 1, Plate 2, Plate 3, Plate 4 
Sheet5
Cell Formulas
RangeFormula
C1:C6C1=IF(ISNUMBER(SEARCH($E$2,B1)),A1,"")
 
Upvote 0
Another option is to use VBA and this routine with a helper column::

Code:
Function aconcat(a As Variant, Optional sep As String = " ") As String
' Harlan Grove, Mar 2002
    Dim y As Variant


    If TypeOf a Is Range Then
        For Each y In a.Cells
            aconcat = aconcat & y.Value & sep
        Next y
    ElseIf IsArray(a) Then
        For Each y In a
            aconcat = aconcat & y & sep
        Next y
    Else
        aconcat = aconcat & a & sep
    End If


    aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function

temporary.xlsm
ABCDE
1ApplePlate 1, Plate 3, Plate 5 #VALUE!
2OrangePlate 1, Plate 2, Plate 4, Plate 5Orange19Plate 4
3PineapplePlate 5 #VALUE!
4MangoPlate 1, Plate 4, Plate 5Mango10
5BerriesPlate 5 #VALUE!
6BananaPlate 1, Plate 2, Plate 3, Plate 4Banana28
7
8Orange Mango Banana
Sheet5
Cell Formulas
RangeFormula
C1:C6C1=IF(ISNUMBER(SEARCH($E$2,B1)),A1,"")
D1:D6D1=SEARCH($E$2,B1)
B8B8=TRIM(MID(aconcat(IF(ISNUMBER(D1:D6)," "&A1:A6,"")),1,999))
 
Upvote 0
Another option would be to maintain your data more properly as shown below. You will then be in to slice and dice your data much more easily. Also you could easily use a Pivot Table to accomplish what you want.

Book1
ABCDE
1BasketPlatePlatePlate 2
2ApplePlate 1
3OrangePlate 1Banana
4MangoPlate 1Orange
5BananaPlate 1
6OrangePlate 2
7BananaPlate 2
8ApplePlate 3
9BananaPlate 3
10OrangePlate 4
11MangoPlate 4
12BananaPlate 4
13ApplePlate 5
14OrangePlate 5
15PineapplePlate 5
16MangoPlate 5
17BerriesPlate 5
Sheet2
 
Upvote 0
As a follow-up, if you see/understand why storing your data as I suggested is a better alterative (and you are able to), you can use code like this to split your data out as shown. Your data would have to be in the exact format as shown in your OP. That is to say that the data that is contained in the Plates column contain a comma and a space between each item contained in each cell.

Please test on a copy of your data as this code will overwrite to your data and it will be essentially unrecoverable.

VBA Code:
Sub SplitPlates()
    Dim pLates, arr
    Dim i As Long, ct As Long, r As Long
    Application.ScreenUpdating = False
    r = 2
    arr = Range("A2:B" & Cells(Rows.Count, 1).End(xlUp).Row)
    For i = 1 To UBound(arr)
        pLates = Split(arr(i, 2), "," & " ")
        ct = UBound(pLates)
        Range("A" & r).Resize(UBound(pLates) + 1) = arr(i, 1)
        Range("B" & r).Resize(UBound(pLates) + 1) = Application.Transpose(pLates)
        r = r + ct + 1
    Next
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thank you all for the replies. I was able to achieve the preferred result using search function. Thank you

@kweaver.​

 
Upvote 0
Welcome to Mr. Excel.

Please clarify how you want the results presented. With 365 it's rather easy.
With 2019 you might consider:

temporary.xlsm
ABCDE
1ApplePlate 1, Plate 3, Plate 5Apple
2OrangePlate 1, Plate 2, Plate 4, Plate 5OrangePlate 5
3PineapplePlate 5Pineapple
4MangoPlate 1, Plate 4, Plate 5Mango
5BerriesPlate 5Berries
6BananaPlate 1, Plate 2, Plate 3, Plate 4 
Sheet5
Cell Formulas
RangeFormula
C1:C6C1=IF(ISNUMBER(SEARCH($E$2,B1)),A1,"")
Hai. Apologies first. I tried to get the work done with the formula you sent me. It does the job. But I've not given you the full idea of what I'm trying to accomplish with the sheet. I thought of doing things myself with the idea you gave (So that I can learn in the process). However., It made things complicated. So I'll present the whole sheet to you.

Report.jpg


As you can see, I have a drop-down at A1. The idea is., if I select a sector from the drop-down list., the data below should get filtered. (Eg: If I select sector 1 in the dropdown, then only row 3, 5, 10, 11, 13 and 17 should be visible for me to edit.)
The data is massive. Around 750 persons with 35 sectors. Each person may be assigned with one sector or multiple sectors. Color changes are done by conditional formatting. And the problem is., It has to be done without macros or VBAs using google sheets.

Link for Example sheet: Report Sheet

Thank you.
 
Upvote 0
It would have been nice to have this information in your OP. People here freely donate their time. If you could not use macros, that should have been stated. Good luck.
 
Upvote 0
I apologise again to you all for not giving clear information. I learned many new things from the macros and VBA posted here. Please don't think it was wasted. I'm curious to know how this can be solved. Please help me with this.
Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top