[COLOR=Blue]Private[/COLOR] [COLOR=Blue]Sub[/COLOR] Workbook_BeforeSave([COLOR=Blue]ByVal[/COLOR] SaveAsUI [COLOR=Blue]As[/COLOR] [COLOR=Blue]Boolean[/COLOR], Cancel [COLOR=Blue]As[/COLOR] [COLOR=Blue]Boolean[/COLOR])
[COLOR=Blue]Call[/COLOR] SaveSelections
[COLOR=Blue]End[/COLOR] [COLOR=Blue]Sub[/COLOR]
[COLOR=Blue]Private[/COLOR] [COLOR=Blue]Sub[/COLOR] Workbook_Open()
[COLOR=Blue]Call[/COLOR] RestoreSelections
[COLOR=Blue]End[/COLOR] [COLOR=Blue]Sub[/COLOR]
[COLOR=Blue]Private[/COLOR] [COLOR=Blue]Sub[/COLOR] SaveSelections()
[COLOR=Blue]Dim[/COLOR] arr() [COLOR=Blue]As[/COLOR] [COLOR=Blue]Variant[/COLOR], i [COLOR=Blue]As[/COLOR] [COLOR=Blue]Long[/COLOR], j [COLOR=Blue]As[/COLOR] [COLOR=Blue]Long[/COLOR]
[COLOR=Blue]With[/COLOR] Sheet1.OLEObjects("ListBox1").Object
[COLOR=Blue]If[/COLOR] .ListIndex > 0 [COLOR=Blue]Then[/COLOR]
[COLOR=Blue]For[/COLOR] i = 0 [COLOR=Blue]To[/COLOR] .ListCount - 1
[COLOR=Blue]If[/COLOR] .Selected(i) [COLOR=Blue]Then[/COLOR]
j = j + 1
[COLOR=Blue]ReDim[/COLOR] [COLOR=Blue]Preserve[/COLOR] arr(1 [COLOR=Blue]To[/COLOR] j)
arr(j) = i
[COLOR=Blue]End[/COLOR] [COLOR=Blue]If[/COLOR]
[COLOR=Blue]Next[/COLOR]
Names.Add Name:="Selections", RefersTo:=arr, Visible:=[COLOR=Blue]False[/COLOR]
[COLOR=Blue]End[/COLOR] [COLOR=Blue]If[/COLOR]
[COLOR=Blue]End[/COLOR] [COLOR=Blue]With[/COLOR]
[COLOR=Blue]End[/COLOR] [COLOR=Blue]Sub[/COLOR]
[COLOR=Blue]Private[/COLOR] [COLOR=Blue]Sub[/COLOR] RestoreSelections()
[COLOR=Blue]Dim[/COLOR] arr [COLOR=Blue]As[/COLOR] [COLOR=Blue]Variant[/COLOR], i [COLOR=Blue]As[/COLOR] [COLOR=Blue]Integer[/COLOR]
arr = [Selections]
[COLOR=Blue]With[/COLOR] Sheet1.OLEObjects("ListBox1").Object
[COLOR=Blue]For[/COLOR] i = 1 [COLOR=Blue]To[/COLOR] [COLOR=Blue]UBound[/COLOR](arr)
.Selected(arr(i)) = [COLOR=Blue]True[/COLOR]
[COLOR=Blue]Next[/COLOR]
[COLOR=Blue]End[/COLOR] [COLOR=Blue]With[/COLOR]
[COLOR=Blue]End[/COLOR] [COLOR=Blue]Sub[/COLOR]