我正在使用此处的视频教程创建Excel VBA Listbox MultiSelect来填充其他ListBox:
https://www.youtube.com/watch?v=dWTEUWqlQAc
基本上,这意味着,“ Excel,如果我从列表框1中选择这些项目,该列表框从Excel列C获得了一系列值,请向我返回同一行中Excel列A的值列表”
但是,我不断收到错误消息“编译错误,无效使用属性”
这将在此处突出显示此代码:
Private Sub ListBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
我不确定自己在做什么错。是因为我正在使用多页代码还是使用此代码?
我尝试重新观看该死的教程,但似乎无济于事。
Private Sub ListBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'find lastrow
lastrow = ThisWorkbook.Worksheets("List of Emails").Cells(Rows.Count, 1).End(xlUp).Row
'clear listbox1
Me.ListBox2.Value
'not just one value, but whichever were selected
For SelItm = LBound(Me.ListBox1.Email) To UBound(Me.ListBox1.Email)
If Me.ListBox1.Selected(SelItm) = True Then
'It is selected
curVal = Me.ListBox1.List(SelItm, 0)
For X = 2 To lastrow
If emails.Cells(X, "c") = curVal Then
'found a match; populate listbox2
Me.ListBox2.AddItem ThisWorkbook.Worksheets("List of Emails").Cells(X, "a")
End If
Next X
End If
Next SelItm
End Sub
无论我怎么努力,我都无法摆脱错误消息。像wtf是“编译错误无效使用属性”吗?我做的和YouTube指南完全一样。
感谢任何人都可以提供任何形式的帮助。谢谢!