Create dropdown list and display different values from another worksheet

Jane_Hogan

New Member
Joined
Sep 20, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have created several dropdown lists on a worksheet which all need to display different values in order to provide input for a name generator cell (using the textjoin formula). I found a VBA code which let's me display different values in a dropdown list ; For example sheet1 shows a dropdown list in column B with the option water which displays as 'WA' and Thee as 'TH' and so on. I would like to apply the same to the dropdown lists in column C to E but I'm unable to solve 2 problems:
1) The VBA code only works with the active sheet (=Sheet1). What code should I use to reference the other sheet (=DropDownValues)? I prefer to keep the dropdown values on a separate sheet so it can be hidden.
2) Sheet1 has several dropdown lists (column B to E) which need to display different values coming from different tables/cells. I tried to use the same VBA code for the other dropdown values on the active sheet but it's not working and I'm seeing a compile error (see screenshots)). How can I apply similar VBA codes in one project/sheet?

Thank you for your help!

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

ProductName = Target.Value

If Target.Column = 2 Then

ProductCode = Application.VLookup(ProductName, ActiveSheet.Range("BUValue"), 2, False)

If Not IsError(ProductCode) Then

Target.Value = ProductCode

End If

End If

End Sub


Thank you for your help!
 

Attachments

  • Screenshot DropdownValues.png
    Screenshot DropdownValues.png
    46.8 KB · Views: 30
  • Screenshot sheet 1.png
    Screenshot sheet 1.png
    63.1 KB · Views: 36
  • Screenshot VBA code.png
    Screenshot VBA code.png
    102.1 KB · Views: 34
  • Screenshot VBA compile error.png
    Screenshot VBA compile error.png
    81.5 KB · Views: 35

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,951
Members
449,095
Latest member
nmaske

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