Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default LIST WITH FACILITY TO ADD TO THIS

hello friends

can we create a listbox or anything like that with a few values to select
and
if a value is selected we must be able to add some more words to it
eg. suppose the list box values are A,B,C and D
If A is selected add €ś 100 apples€ť to it ...like that

THANK YOU...

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default LIST WITH FACILITY TO ADD TO THIS

Do you mean a dropdown list in a worksheet cell, or do you mean a listbox on
a userform? When the selection is subsequently edited, should that change the
list of valid items for the listbox (so that next time, 'A 100 apples'
appears in the dropdown list)?

If you mean a dropdown list in a cell, you can create it using data
validation. The best way is to enter the valid choices in contiguous cells on
another sheet. Select all those cells and assign them a range name (for
example, MyList). In the cell where you want the dropdown list, select Data
Validation. On the Settings tab, change the Allow setting to List and ener

=MyList as the source. On the Error Alert tab, uncheck the box to 'Show error
alert after invalid data is entered'. Click OK to close the Data Validation
dialog. Now you can select an entry from MyList, then edit it without an
error message. This doesn't change the list of valid entries for the cell -
it is still defined by MyList. To "permanently" change A to 'A 100 apples'
you would edit the cell in MyList that contains A.

If you mean a listbox on a userform, here is a simple example. I created a
userform (UserForm1) with a combobox (ComboBox1) and 2 textboxes (TextBox1
and TextBox2) on it. I sized and placed them so that TextBox1 exactly covers
ComboBox1. When TextBox1 is double-clicked it is hidden and the combobox is
shown. Selecting a value from the combobox puts that value in TextBox1, where
it can be edited. IF you don't want to update the list of items in the
combobox, this is all you need. To update the list of combobox item, when you
exit TextBox1 the code checks if it matches the last item selected from the
combobox + more text. If yes, the last item selected from the combobox is
removed from list of combobox items and the current value of TextBox1 is
added. The code is crude but may give you a starting point, if this is what
you are trying to do.

Option Explicit

Public CurrItm As String
Public ChgFlag As Boolean

Private Sub ComboBox1_Change()
CurrItm = ComboBox1.Value
Me.ComboBox1.Visible = False
Me.TextBox1.Value = ComboBox1.Value
Me.TextBox1.Visible = True
ChgFlag = True
End Sub

Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Visible = False
Me.ComboBox1.Visible = True
ChgFlag = False
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim tmp As String, x As Long
tmp = TextBox1.Value
On Error Resume Next
If Left(TextBox1.Value, Len(CurrItm)) = CurrItm And _
(TextBox1.Value < ComboBox1.Value) And (ChgFlag = True) Then
For x = 0 To ComboBox1.ListCount - 1
If ComboBox1.List(x) = CurrItm Then
Me.ComboBox1.RemoveItem x
Me.ComboBox1.ListIndex = -1
End If
Next x
TextBox1.Value = tmp
Me.ComboBox1.AddItem TextBox1.Value
CurrItm = TextBox1.Value
End If
End Sub

Private Sub UserForm_Initialize()
Me.ComboBox1.AddItem "A"
Me.ComboBox1.AddItem "B"
Me.ComboBox1.AddItem "C"
Me.ComboBox1.AddItem "D"
ChgFlag = False
End Sub

Hope this helps,

Hutch

"evelin via OfficeKB.com" wrote:

hello friends

can we create a listbox or anything like that with a few values to select
and
if a value is selected we must be able to add some more words to it
eg. suppose the list box values are A,B,C and D
If A is selected add €ś 100 apples€ť to it ...like that

THANK YOU...

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

.

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
List Box with lookup facility Col Excel Worksheet Functions 1 October 14th 08 01:49 AM
Spelling Facility Zygy New Users to Excel 2 December 11th 06 05:49 PM
Search Facility anar_baku[_4_] Excel Programming 2 August 25th 05 12:03 PM
'Group by' facility? Steve W[_2_] Excel Programming 3 March 4th 05 04:31 PM
search facility darren Excel Programming 2 June 9th 04 09:54 AM


All times are GMT +1. The time now is 08:53 PM.

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"