Listbox populating progmatically
Rick,
You have clearly demonstrated that you know how to add the item.
If you looked at ListIndex in help you should have gathered that Listindex
points at the item in the list that is selected. pair this with the
RemoveItem method, and you can delete the selected item
With Me.ListBox1
.RemoveItem (.ListIndex)
End With
--
---
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
"Rick S." wrote in message
...
Thank you Bob, I can now Add and/or Remove Items from my Listbox!
What I am failing to see is how to append, add or remove the Items to my
hard coded list. I have never tried to write code into a macro before and
I
am not finding information "How to", I may not know what to search for?
Below is my list that I need to append, add or remove lines from.
'==========
Private Sub UserForm_Initialize()
Me.ListBox1.AddItem ("1")
Me.ListBox1.AddItem ("2")
Me.ListBox1.AddItem ("3")
Me.ListBox1.AddItem ("4")
Me.ListBox1.AddItem ("5")
End Sub
'==========
I am not looking just for "The Code"; direction like you have provided is
allways welcome!
--
Regards
Rick
XP Pro
Office 2007
"Bob Phillips" wrote:
Look at ListIndex in VBA help, it should give you what you want
--
---
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my
addy)
"Rick S." wrote in message
...
I have this list (for a listbox), condensed for this query..
'=====================
Private Sub UserForm_Initialize()
Me.ListBox1.AddItem ("1")
Me.ListBox1.AddItem ("2")
Me.ListBox1.AddItem ("3")
Me.ListBox1.AddItem ("4")
Me.ListBox1.AddItem ("5")
End Sub
'================
How do I read from that list and create code to mimick the following.
'==============
With ListBox1
If .Value = "1" Then
If .Value = "2" Then
If .Value = "3" Then
If .Value = "4" Then
If .Value = "5" Then
End If
End If
End If
End If
End If
'some code goes here
End With
'===============
I would like to prevent constant editing of the macro to accomidate new
entries.
--
Regards
Rick
XP Pro
Office 2007
|