复选框不显示

时间:2014-07-15 19:17:06

标签: excel-vba vba excel

我有这个代码,假设从文件中复制列标题,并将这些标题作为checkboxess添加到清单中。但是当我执行代码时,它将复制列标题但不会创建复选框。知道为什么它没有?

 If sj = True Or ji = True Then
    For j = 1 To 199
         If Trim(wks1.Cells(4, j).Value) = "" Then
            titlesj = j - 1
            Exit For
        End If
            jTitles(j - 1) = wks1.Cells(4, j).Value
     Next

     j = 1

     ' Add column titles from files into the listbox as checkboxes
     For j = 0 To titlesj
        Sheet1.ListBox1.AddItem jTitles(j)
        Sheet1.ListBox3.AddItem jTitles(j)
     Next
     wb1.Close
End If 

1 个答案:

答案 0 :(得分:1)

试试这个......将“Listbox1”和“ListBox3”的ListStyle和MultiSelect属性设置为“1”。在两个循环之前放置以下内容。

Sheet1.ListBox1.ListStyle = 1
Sheet1.ListBox1.MultiSelect = 1
Sheet1.ListBox3.ListStyle = 1
Sheet1.ListBox3.MultiSelect = 1

来源:http://www.excelforum.com/excel-programming-vba-macros/685957-listbox-with-checkboxes.html