Dropdown list question

Deadly48

New Member
Joined
Jun 14, 2006
Messages
19
I have a dropdown list of document types in cell A1. Drawings, Word docs, Excel docs, etc… I want to fill cell A1 with a code dependant on the doc type selected from the dropdown list.
e.g. select “Drawings” from dropdown. Code to be displayed in cell A1 “DRG”
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try this:

The script will run when you enter a value in Range("A1")

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  1/29/2019  1:41:56 PM  EST
If Target.Address = "$A$1" Then
Application.EnableEvents = False
With Target
    Select Case Target.Value
        Case "Drawings"
            .Value = "DRG"
        Case "Word docs"
            .Value = "Ms Word is great"
        Case "Excel docs"
            .Value = "Mr.Excel"

    End Select
End With
Application.EnableEvents = True
End If
End Sub
 
Last edited:
Upvote 0
Try this:

The script will run when you enter a value in Range("A1")

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  1/29/2019  1:41:56 PM  EST
If Target.Address = "$A$1" Then
Application.EnableEvents = False
With Target
    Select Case Target.Value
        Case "Drawings"
            .Value = "DRG"
        Case "Word docs"
            .Value = "Ms Word is great"
        Case "Excel docs"
            .Value = "Mr.Excel"

    End Select
End With
Application.EnableEvents = True
End If
End Sub

Hi, Thank you this works fine I've attached the code I have modified see below.
I have one more question how can I change this to be a range in column D or the whole column, rather than a specific cell

Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 1/29/2019 1:41:56 PM EST
If Target.Address = "$D$1" Then
Application.EnableEvents = False
With Target
Select Case Target.Value
Case "General document"
.Value = "GD"
Case "Technical requisition"
.Value = "TR"
Case "Technical specification"
.Value = "TE"
Case "Civil drawing"
.Value = "DC"
Case "Mechanical drawing"
.Value = "DM"
Case "Electrical drawing"
.Value = "DE"
Case "General drawing"
.Value = "DG"
End Select
End With
Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Try this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  1/30/2019  5:53:56 AM  EST
If Target.Column = 4 Then
If Target.CountLarge > 1 Then Exit Sub
Application.EnableEvents = False
With Target
Select Case Target.Value
Case "General document"
.Value = "GD"
Case "Technical requisition"
.Value = "TR"
Case "Technical specification"
.Value = "TE"
Case "Civil drawing"
.Value = "DC"
Case "Mechanical drawing"
.Value = "DM"
Case "Electrical drawing"
.Value = "DE"
Case "General drawing"
.Value = "DG"
End Select
End With
Application.EnableEvents = True
End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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