activeX multiselect list doesn't save when exiting

jab973

New Member
Joined
Feb 13, 2015
Messages
11
Office Version
  1. 365
Platform
  1. Windows
I have created a small macro to display a checklist that can by checked off and says "Complete" once all items have been checked. I created this using ActiveX Listbox with multiselect. However, when the file is saved and reopened, all the check marks clear out. Is there a way to fix this so they stay checked? Maybe with OLEObject, but I don't understand how to use that?

Thanks for any assistance!

Private Sub listbox1_change()
Call checklist
End Sub
Private Sub ListBox1_Click()
Call checklist
End Sub




Sub checklist()
Sheet1.Cells(1, 1).Clear


With Sheet1.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = False Then Sheet1.Cells(1, 1) = "NOT Complete"
Next i
If Sheet1.Cells(1, 1) = "" Then Sheet1.Cells(1, 1) = "Complete"
End With
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
One option is to store the values on a sheet.
I've used col Z on the same sheet as the listbox
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim Cnt As Long

    With Sheet1.ListBox1
        For Cnt = 0 To .ListCount - 1
            Sheet1.Range("Z" & Cnt + 1) = .Selected(Cnt)
        Next Cnt
    End With

End Sub


Private Sub Workbook_Open()
    Dim Cnt As Long

    With Sheet1.ListBox1
        For Cnt = 0 To .ListCount - 1
            .Selected(Cnt) = Sheet1.Range("Z" & Cnt + 1)
        Next Cnt
    End With

End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top