Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Got a little challenge any ?

Thanks to Tom I got the following:

Private Sub Combobox1_Click()
Dim res As Variant
res = Application.Match(CDbl(ComboBox1.Value), _
Worksheets("Sheet3").Range("A1:A20"), 0)
Worksheets("Sheet1").Range("G7").Value = _
Worksheets("Sheet3").Range("B1:B20")(res).Value

End Sub

the following is the range A1:A20 in Sheet3:

...A..............B

North
10000....North st1
10001....North st2
10002...'...you get the point
10003
South
10004
10005
10006
10007
West
10008
'...and so on

the above code only allows numbers to be chosen from the combobox, wh
can the code be tweaked to allow non numeric characters to be selecte
(i.e. "North", "South", etc???

- Larry -
VBA Amateur .... but learning :

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Got a little challenge any ?

Hi Larry,

Here is one way

Private Sub Combobox1_Click()
Dim res As Variant
On Error Resume Next
res = Application.Match(CDbl(ComboBox1.Value), _
Worksheets("Sheet3").Range("A1:A20"), 0)
If Err.Number < 0 Then
res = Application.Match(ComboBox1.Value, _
Worksheets("Sheet3").Range("A1:A20"), 0)
End If
On Error GoTo 0
Worksheets("Sheet1").Range("G7").Value = _
Worksheets("Sheet3").Range("B1:B20")(res).Value

End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"nrage21 " wrote in message
...
Thanks to Tom I got the following:

Private Sub Combobox1_Click()
Dim res As Variant
res = Application.Match(CDbl(ComboBox1.Value), _
Worksheets("Sheet3").Range("A1:A20"), 0)
Worksheets("Sheet1").Range("G7").Value = _
Worksheets("Sheet3").Range("B1:B20")(res).Value

End Sub

the following is the range A1:A20 in Sheet3:

..A..............B

North
10000....North st1
10001....North st2
10002...'...you get the point
10003
South
10004
10005
10006
10007
West
10008
'...and so on

the above code only allows numbers to be chosen from the combobox, who
can the code be tweaked to allow non numeric characters to be selected
(i.e. "North", "South", etc???

- Larry -
VBA Amateur .... but learning :)


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Got a little challenge any ?

Thanks Bob!
as always so helpful

- Larry -
VBA Amateu

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Who's up for a Challenge? Growe1 Excel Worksheet Functions 4 March 16th 09 05:33 AM
Challenge for Anyone to take it on. SO CONFUSED Excel Worksheet Functions 4 November 12th 08 10:42 AM
A challenge doss04 New Users to Excel 0 October 22nd 08 08:03 AM
A Challenge Jazzer Excel Worksheet Functions 3 July 8th 05 05:08 PM
This May Be A Challenge Jose Rojas Excel Programming 0 September 11th 03 11:52 PM


All times are GMT +1. The time now is 11:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"