Listbox Problem

B

browie

I have a list box which I have set up which runs a message bank. I would
like it to have the ability to delete the sected message from the worksheet.
How can I do this?

userform name is "splash"

listbox1 its rowsource is messagesa2:a1000
and the button i wish to use to delete is commandbutton2

any help with the code would be great

Thanks

Greg
 
B

Bob Phillips

Private Sub CommandButton2_Click()
Worksheets("Messages").Range("A2").Offset(ListBox1.ListIndex).Delete
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

browie

Thanks will try it now

Greg
Bob Phillips said:
Private Sub CommandButton2_Click()
Worksheets("Messages").Range("A2").Offset(ListBox1.ListIndex).Delete
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

browie

Bob

How can it be changed to delete the whole row.
sorry I just noticed I wrote it as a1:a1000 where it should be e1000

Private Sub CommandButton2_Click()
Worksheets("Messages").Range("A2").Offset(ListBox1.ListIndex).Delete
End Sub


Thanks in advance
Greg
 
B

Bob Phillips

Private Sub CommandButton2_Click()

Worksheets("Messages").Range("A2").Offset(ListBox1.ListIndex).Entirerow.Dele
te
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

browie

Thanks Bob works Great

Greg
Bob Phillips said:
Private Sub CommandButton2_Click()

Worksheets("Messages").Range("A2").Offset(ListBox1.ListIndex).Entirerow.Dele
te
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

listbox 4
Creating a lookup in a userform 4
list box 2
Listbox Query Again 1
ListBox Remove Certain Text 6
Password userform activate 2
Populating a ListBox with an Array 1
Loop through userform 2

Top