用户双击特定工作表中的任何单元格后,我正在初始化用户窗体。一个或几个初始化后,excel文件停止工作。请帮助解决此问题。 该表单包含一个使用多维数组填充的列表框。此数组使用包含6列和不同行数的单元格区域中的值进行填充。这是我的代码:
Private Sub UserForm_Initialize()
Dim lr, plr As Long
Dim a As Variant
Set psh = ThisWorkbook.Sheets("P")
psh.Activate
lr = GetFilteredRangeBottomRow() 'function to get row number of lastrow from filtered range
psh.Range("A1:F" & lr).SpecialCells(xlCellTypeVisible).Copy
On Error Resume Next
psh.Range("BA1").PasteSpecial xlPasteValues
psh.ShowAllData
plr = psh.Columns(53).Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row 'last row in column BA
a = psh.Range("BA1:BF" & plr).Value
With Form1.LBx 'LBx is the list box I am trying to populate
.ColumnCount = 6
.List = a
End With
End Sub