Drop down list question

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
I enter my mileage onto a spreadsheet for various garages.
I wish to have a drop down list with the garages name & miles to & from there.

In the drop down list i would need to see the name of the garage & also the miles BUT when i make my selection i would only require the mileage to be entered into the cell.


The worksheet is called MILEAGE & the drop down list will be placed into cells D3:D30

Is this possible if so please advise.

Many thanks.
 
Thanks for that.
Ive just popped out for half hour but asking if I type b and not B then the code will not work.
How can it be written so b or B will enter 1
small & upper case.
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi,
I have applied the code you mentioned as show below.
The problem is say i type W in cell D3 and then i move to cell D4, cell D3 still shows W, If i then click back into cell D3 it only then changes to 5

With my code shown above as soon as i moved from the cell in question the letter would change to its numerical value.


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)If Selection.Count = 1 Then
If Not Intersect(Target, Range("D3:D30")) Is Nothing Then




If Target.Value = "b" Then Target.Value = "1"
If UCase(Target.Value = "B") Then Target.Value = "1"
If Target.Value = "l" Then Target.Value = "4"
If UCase(Target.Value = "L") Then Target.Value = "4"
If Target.Value = "w" Then Target.Value = "5"
If UCase(Target.Value = "W") Then Target.Value = "5"
If Target.Value = "h" Then Target.Value = "6"
If UCase(Target.Value = "H") Then Target.Value = "6"
If Target.Value = "c" Then Target.Value = "7"
If UCase(Target.Value = "C") Then Target.Value = "7"


End If
End If


End Sub
 
Upvote 0
here is the entire code you need

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


If Not Intersect(Target, Range("D3:D30")) Is Nothing Then


If UCase(Target.Value) = "B" Then Target.Value = "1"
If UCase(Target.Value) = "L" Then Target.Value = "4"
If UCase(Target.Value) = "W" Then Target.Value = "5"
If UCase(Target.Value) = "H" Then Target.Value = "6"
If UCase(Target.Value) = "C" Then Target.Value = "7"


End If

End Sub

hth,

Ross
 
Last edited:
Upvote 0
Give this a try.
Works for the garage name like Regal Garage 26 where it returns 26, but if you have a garage name like Mick's Rte. 44 grg 66 then it will return 4466.

Copy the code to the MILAGE sheet module. When you select a garage from a drop down in the D3:D30 you get the number in the adjacent cell.

Howard

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Intersect(Target, Me.Range("$D$3:$D$30"))
If isect Is Nothing Then Exit Sub

Dim tADD As String

tADD = Target.Address

With Target.Offset(, 1)
  .Formula = ("=SUMPRODUCT(MID(0&" & tADD & ",LARGE(INDEX(ISNUMBER(--MID(" & tADD & ",ROW($1:$25),1))* ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10)")
  .Value = .Value
End With

End Sub
 
Upvote 0
Give this a try.
Works for the garage name like Regal Garage 26 where it returns 26, but if you have a garage name like Mick's Rte. 44 grg 66 then it will return 4466.

Copy the code to the MILAGE sheet module. When you select a garage from a drop down in the D3:D30 you get the number in the adjacent cell.

Howard

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Intersect(Target, Me.Range("$D$3:$D$30"))
If isect Is Nothing Then Exit Sub

Dim tADD As String

tADD = Target.Address

With Target.Offset(, 1)
  .Formula = ("=SUMPRODUCT(MID(0&" & tADD & ",LARGE(INDEX(ISNUMBER(--MID(" & tADD & ",ROW($1:$25),1))* ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10)")
  .Value = .Value
End With

End Sub

Sorry about this post here! Seems to be in the wrong thread to be sure... I have no idea how I got here instead of the thread looking to extract a number from a text string.

Howard
 
Upvote 0
Sorry about this post here! Seems to be in the wrong thread to be sure... I have no idea how I got here instead of the thread looking to extract a number from a text string.

Howard

I remain confused... my post was indeed intended for this thread. Don't know if OP used it or not. Appears the problem was solved.

Howard
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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