Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Remove items from a listbox

I was wondering if anyone can help me, I have a listbox on a form in excel
that has row source of a data range from one of the sheets(called LIST). I
would like to add a button to the form that when clicked will remove the
currently selected item from the listbox and also removesthe corresponding
values from the worksheet.

Also, is it possible to take the removed values and paste them elsewhere on
the sheet?

Any help would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Remove items from a listbox

Dim iRow As Long
With Me.ListBox1
On Error Resume Next
iRow = Application.Match(.Value, Range(.RowSource), 0)
On Error GoTo 0
If iRow 0 Then
Range(.RowSource).Cells(iRow, 1).EntireRow.Delete
End If
End With


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Andy" wrote in message
...
I was wondering if anyone can help me, I have a listbox on a form in excel
that has row source of a data range from one of the sheets(called LIST). I
would like to add a button to the form that when clicked will remove the
currently selected item from the listbox and also removesthe corresponding
values from the worksheet.

Also, is it possible to take the removed values and paste them elsewhere

on
the sheet?

Any help would be greatly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Remove items from a listbox

I appreciate the help, but the code you supplied is having problems as it
wasn't doing anything when the button was pressed. When I removed the on
error commands, it told me that the following line had a type mismatch error:

iRow = Application.Match(.Value, Range(.RowSource), 0)




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Remove items from a listbox

That means it cannot find the data in the data.

What does the data look like, and where is it (cells) and what is your final
code?

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Andy" wrote in message
...
I appreciate the help, but the code you supplied is having problems as it
wasn't doing anything when the button was pressed. When I removed the on
error commands, it told me that the following line had a type mismatch

error:

iRow = Application.Match(.Value, Range(.RowSource), 0)






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Remove items from a listbox

The data source for the list box is 5 columns on a spreadsheet (A:E), first
column contains numbers, second text, third numbers, fourth text and fifth
text.

The code i'm not too sure about as I was having problems getting it to
remove the item from the listbox and the corresponding data in the cells, so
the button the code is applied to is actually blank at the moment.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Remove items from a listbox

show us the code that is a problem.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Andy" wrote in message
...
The data source for the list box is 5 columns on a spreadsheet (A:E),

first
column contains numbers, second text, third numbers, fourth text and fifth
text.

The code i'm not too sure about as I was having problems getting it to
remove the item from the listbox and the corresponding data in the cells,

so
the button the code is applied to is actually blank at the moment.



Reply
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
add items to listbox Baha Excel Programming 1 November 24th 06 01:44 AM
Remove all Listbox items Todd Huttenstine Excel Programming 3 July 12th 04 09:56 PM
Adding Items to a ListBox-Unique Items Only jpendegraft[_14_] Excel Programming 2 May 2nd 04 02:27 AM
Items in a Listbox Todd Huttenstine Excel Programming 1 April 26th 04 03:36 PM
Simple Listbox question - how to remove items TBA[_2_] Excel Programming 3 January 10th 04 02:18 AM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"