Need to display only portion of LIST selection

beansinCA

New Member
Joined
May 14, 2004
Messages
19
Using Data-Validation I have setup a list at D1 using source =$M$1:$M$4

The source data is: M1="100 Customer 1", M2="101 Customer 2", M3="102 Customer 3", M4="103 Customer 4"

When a user selects an item from the list I just want to display the left three characters of the string (i.e. 100 if first selection is made). Is this doable in Excel?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

beansinCA

New Member
Joined
May 14, 2004
Messages
19
I can do that if there is no alternative but prefer to have the result show in D1
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,884
Hi beansinCA

In that case I believe you have to use the Change Event of the worksheet and extract the first 3 characters of the value.

Hope this helps
PGC
 

beansinCA

New Member
Joined
May 14, 2004
Messages
19
Hi PGC,
I'm not sure what you mean by use Change Event. Can you provide a little more detail?

Thanks!
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,884
Hi again

Paste this code in the module sheet (right-click on the sheet tab, choose view code, check that the highlighted module is the module of the sheet where D1 is, and paste this code).

Hope this helps
PGC

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$D$1" Then _
        Target.Value = Left(Target.Value, 3)
End Sub
 

Forum statistics

Threads
1,141,761
Messages
5,708,367
Members
421,566
Latest member
7Nabisco

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
Top