LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Combobox display 1 value, access another

One mo

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
With Me.ComboBox1
If .ListIndex < 0 Then
'nothing selected
Beep
Exit Sub
End If

MsgBox .List(.ListIndex, 1)
End With
End Sub
Private Sub UserForm_Initialize()
Dim LastRow As Long
Dim iCtr As Long
Dim wks As Worksheet

Set wks = Worksheets("Data")

With wks
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
End With

With Me.ComboBox1
.ColumnCount = 2
.ColumnWidths = "55;0" 'hide the second column
For iCtr = 5 To LastRow
.AddItem wks.Cells(iCtr, "B").Value
.List(.ListCount - 1, 1) = wks.Cells(iCtr, "A").Value
Next iCtr
End With
End Sub


lcoreilly wrote:

Hi All,
I have a combobox that gets filled with the following code:

'load combobox with list of grantee institutions
With ComboBox1
For i = 5 To LastRow
.AddItem Worksheets("data").Cells(i, 2)
Next i
End With

End Sub

The drop down menu contains a list of schools, but the data element I
really need access to is the ID number, which is in column A. Is
there a way to access this value? Maybe using the offset function? I
can't seem to figure it out.

Thanks in advance.


--

Dave Peterson
 
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
MultiColumn ComboBox Display Minitman Excel Programming 4 June 1st 08 05:54 AM
Combobox display on startup Richard New Users to Excel 5 September 6th 05 01:02 PM
MultiColumn ComboBox Value set/display Jim Zeeb[_2_] Excel Programming 5 June 13th 05 09:20 AM
Combobox & Display Bhuktar S[_12_] Excel Programming 1 October 2nd 04 01:14 AM
Format Display in ComboBox King[_4_] Excel Programming 2 October 13th 03 06:06 PM


All times are GMT +1. The time now is 05:10 PM.

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"