View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_3_] Dick Kusleika[_3_] is offline
external usenet poster
 
Posts: 599
Default Desperate for help with VBA List Box

bluegirl

Yes, you can do that. First, make a userform with a listbox and a
commandbutton. In the Initialize event, put the classes in the listbox. I
don't know where your class list is, but here's an example

Private Sub UserForm_Initialize()

Dim cell As Range

For Each cell In Sheet2.Range("ClassList").Cells
Me.ListBox1.AddItem cell.Value
Next cell

End Sub

Then, in your commandbutton's click event, you need code like this

Private Sub CommandButton1_Click()

If Me.ListBox1.ListIndex = 0 Then
ActiveCell.Value = Me.ListBox1.Value
End If

Unload Me

End Sub

Finally, to show the userform, use the Selection change event.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$A$1" Then 'limit to A1
UserForm1.Show
End If

End Sub


--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


"bluegirl " wrote in message
...
Maybe I need to clarify a little. The problem with making the cell wide
enough to accomodate the entire line of text for the class name is that
it would be way too long.

Is it possible to create a userform box that will pop up for this cell
and after they make their selection it will write it to the
appropriate row?

Once it is selected I have the cell set to word wrap so it will not
take up as much room, it is just viewing the entire line of text that
is the problem.

Does that make sense?


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