Userform Questions

G

Guest

I have a program that is almost done with some bugs I could not seem to fix.
1. Is there a way to save items shown on List 1 (user selection) and List 2
(user selected) after user exits Excel?. My intuition is no since everything
is gone from RAM.
2. List 1 items are imported from data which, have superscripts & subscripts
but when added to the List 1 formatting is lost which cascades into List 2
and dumping items into a sheet.
3. When I select/deselect items and show form again, List 2 items deselected
are duplicated in List 1.

For Row = 7 To 27
RXWIon.List1.AddItem Sheets("Database").Cells(Row, 2)
Next Row

End Sub


Private Sub CommandButton1_Click()
Dim s As String, i As Integer, it As Control
i = List1.ListIndex
s = List1.Text
If List1.ListIndex < 0 Then Exit Sub

If List2.ListCount = 0 Then
List2.AddItem s
Else
p = findpos(s, List2)
If p > -1 Then
List2.AddItem s, p
Else
List2.AddItem s
End If
End If

List1.RemoveItem i

End Sub


Private Sub CommandButton2_Click()
Dim s As String, i As Integer, it As Control
i = List2.ListIndex
s = List2.Text
If List2.ListIndex < 0 Then Exit Sub

If List1.ListCount = 0 Then
List1.AddItem s
Else
p = findpos(s, List1)
If p > -1 Then
List1.AddItem s, p
Else
List1.AddItem s
End If
End If

List2.RemoveItem i

End Sub

Private Sub pbCANCEL_Click()
'
Me.Hide
End Sub

Private Sub pbAccept_Click()
Dim lbx As MSForms.ListBox
Set lbx = Me.List2
With Worksheets("Calcs")
.Range("B7").Resize(lbx.ListCount, 1).Value = lbx.List
End With
Me.Hide.
End Sub

Thanks.

Ligaya
 
T

Tom Ogilvy

1) as you thought You would need to write them to a worksheet and save
the workbook.

2) doesn't support rich text format, so doesn't support super and sub
scripts.

3) Your code seemed to work for me.
 

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


Top