View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel Nigel is offline
external usenet poster
 
Posts: 923
Default Command Button question

You could use the listbox events to control the commandbuttons enabled
status, rather than let the button be pressed only to do nothing!

something like....

sub listbox1_change
if listbox1.listindex = 0 then
commandbutton1.enabled = true
else
commandbuton1.enabled = false
endif
end sub

Put the commandbuton1.enabled = false in the form initialize event.


--
Cheers
Nigel



"Patrick Simonds" wrote in message
...
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