View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Kai Uwe Schmidt Kai Uwe Schmidt is offline
external usenet poster
 
Posts: 7
Default Command Button question

Hi Patrick,

when no selection is made, ListBox.ListIndex has the value -1 (otherwise, it
has a value from 0 to Listbox.Listcount -1).

Public Sub ChangeRowSource ()
If listbox1.listindex = -1 then
MsgBox "Please Select a name first!" : Exit Sub 'quick and very
dirty.
Else
...
End if
End Sub

Regards,
Kai


"Patrick Simonds" schrieb im Newsbeitrag
...
On my UserForm I have a ListBox (ListBox1) and 2 Command Buttons (Edit
Name, Delete Name). When I click on one of the two command buttons it runs
code to go to the source for the ListBox and selects the name and then
allows you to Edit or Delete the name.

What I need is a piece of code which will prevent the code associated to
either Command Button from running if no name is selected in ListBox1


I tried:

EditName ()

If ListBox1.Value = "" Then GoTo BlankList

My Code here

BlankList:

End Sub