Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Select & edit items in a listbox in VBA


Hi All

I would like to know if it is possible to edit a list box directly?

I have a userform with a textbox to add items to a list box on th
form. I want to make it possible for the user to select an item fro
the list and either directly edit it or for the item to be placed i
the textbox for the user to edit. The actuall items in the list ar
stored in one of the sheets and I have defined a name for the range.

I set the value of the textbox = listbox1.value under the MouseDow
event of the listbox. However, I can't think how to update the edite
item back to the listbox. Basically I want to overwrite the old ite
with the new one.

I would appreciate any help.

Thanks

Kind Regard

--
popp
-----------------------------------------------------------------------
poppy's Profile: http://www.excelforum.com/member.php...fo&userid=1145
View this thread: http://www.excelforum.com/showthread.php?threadid=54022

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Select & edit items in a listbox in VBA


Hi Ardus

That piece of code your wrote is doing exactly what I want :) except
that it only works on the first item in the list :( . If I try
selecting a different item from the second one down, it throws a
run-time error 1004 - Application or Object defined error on this line:


Set rCell = Range(.RowSource).Offset(.ListIndex).Resize(1)

I set my rowsource to the name I defined for that list.

Could that be the problem?


--
poppy
------------------------------------------------------------------------
poppy's Profile: http://www.excelforum.com/member.php...o&userid=11453
View this thread: http://www.excelforum.com/showthread...hreadid=540220

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Select & edit items in a listbox in VBA


Hi Ardus

This is what my code looks like:

Code:
--------------------


Private Sub ListBox1_Click()
txtRank.Value = ListBox1.Value
End Sub

Private Sub txtRank_Change()
Dim rCell As Range
With ListBox1
Set rCell = Range(.RowSource).Offset(.ListIndex).Resize(1)
rCell.Value = txtRank.Value
End With
End Sub


Private Sub UserForm_Initialize()

ListBox1.ColumnCount = 1
ListBox1.RowSource = "SourceRank" 'I set it so that when the form is loaded the list in SourceRank(Defined name - Col A:A) is displayed in the listbox, I dont know if this might be the problem or not?

End Sub

--------------------


Kind Regards


--
poppy
------------------------------------------------------------------------
poppy's Profile: http://www.excelforum.com/member.php...o&userid=11453
View this thread: http://www.excelforum.com/showthread...hreadid=540220



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
Problem using INDEX to select items in listbox Shazbot Excel Discussion (Misc queries) 3 April 28th 06 09:06 AM
Listbox Select items with Keyboard. Casey[_75_] Excel Programming 2 April 17th 06 08:26 PM
Select multiple items in a listbox uecem[_4_] Excel Programming 2 November 26th 04 02:00 AM
select mulitiple columns and items from a listbox TK Excel Programming 1 August 26th 04 05:15 AM
SELECT, ERASE, EDIT items in listbox unplugs[_29_] Excel Programming 10 June 30th 04 04:56 AM


All times are GMT +1. The time now is 04:31 PM.

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

About Us

"It's about Microsoft Excel"