Private [COLOR=navy]Sub[/COLOR] UserForm_Initialize()
[COLOR=navy]Dim[/COLOR] Lst1, Lst2, Rng [COLOR=navy]As[/COLOR] Range
[COLOR=navy]On[/COLOR] [COLOR=navy]Error[/COLOR] [COLOR=navy]Resume[/COLOR] [COLOR=navy]Next[/COLOR]
[COLOR=navy]With[/COLOR] Sheets("Sheet2")
Lst1 = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
[COLOR=navy]End[/COLOR] With
Lst2 = Split(Selection, Chr(10))
[COLOR=navy]With[/COLOR] ListA
.List = Application.Transpose(Lst2)
.MultiSelect = fmMultiSelectMulti
[COLOR=navy]End[/COLOR] With
[COLOR=navy]With[/COLOR] ListB
.List = Lst1
.MultiSelect = fmMultiSelectMulti
[COLOR=navy]End[/COLOR] With
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
'[COLOR=green][B]'''''''''''''''''''''''''''''[/B][/COLOR]
Private [COLOR=navy]Sub[/COLOR] But_Add_Click()
[COLOR=navy]Dim[/COLOR] Tran [COLOR=navy]As[/COLOR] [COLOR=navy]Integer,[/COLOR] Ray(), c [COLOR=navy]As[/COLOR] [COLOR=navy]Integer[/COLOR]
c = 0
[COLOR=navy]On[/COLOR] [COLOR=navy]Error[/COLOR] [COLOR=navy]Resume[/COLOR] [COLOR=navy]Next[/COLOR]
[COLOR=navy]For[/COLOR] Tran = 0 To ListA.ListCount - 1
[COLOR=navy]If[/COLOR] ListA.List(Tran) <> "" [COLOR=navy]Then[/COLOR]
ReDim Preserve Ray(c)
Ray(c) = ListA.List(Tran)
c = c + 1
[COLOR=navy]End[/COLOR] If
[COLOR=navy]Next[/COLOR] Tran
[COLOR=navy]For[/COLOR] Tran = 0 To ListB.ListCount - 1
[COLOR=navy]If[/COLOR] ListB.Selected(Tran) [COLOR=navy]Then[/COLOR]
ReDim Preserve Ray(c)
Ray(c) = ListB.List(Tran)
c = c + 1
[COLOR=navy]End[/COLOR] If
[COLOR=navy]Next[/COLOR] Tran
[COLOR=navy]With[/COLOR] ListA
.Clear
.List = Application.Transpose(Ray)
[COLOR=navy]End[/COLOR] With
Selection = Join(Application.Transpose(ListA.List), Chr(10))
Unload Me
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
'[COLOR=green][B]'''''''''''''''''''''''''''''[/B][/COLOR]
Private [COLOR=navy]Sub[/COLOR] But_Remove_Click()
[COLOR=navy]Dim[/COLOR] Tran [COLOR=navy]As[/COLOR] [COLOR=navy]Integer,[/COLOR] c [COLOR=navy]As[/COLOR] [COLOR=navy]Integer,[/COLOR] Ray()
c = 0
[COLOR=navy]For[/COLOR] Tran = 0 To ListA.ListCount - 1
[COLOR=navy]If[/COLOR] Not ListA.Selected(Tran) [COLOR=navy]Then[/COLOR]
ReDim Preserve Ray(c)
Ray(c) = ListA.List(Tran)
c = c + 1
[COLOR=navy]End[/COLOR] If
[COLOR=navy]Next[/COLOR] Tran
Selection.ClearContents
[COLOR=navy]With[/COLOR] ListA
.Clear
[COLOR=navy]If[/COLOR] c > 0 [COLOR=navy]Then[/COLOR]
.List = Application.Transpose(Ray)
Selection = Join(Application.Transpose(ListA.List), Chr(10))
[COLOR=navy]End[/COLOR] If
[COLOR=navy]End[/COLOR] With
Unload Me
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]