excel vba 这段简单的代码该怎么解释,特别是上面那部分。

PrivateSubComboBox1_Change()Dimstr$str=ComboBox1.TextDimdic,arr,iAsIntegerSetdic=Crea... Private Sub ComboBox1_Change()
Dim str$
str = ComboBox1.Text
Dim dic, arr, i As Integer
Set dic = CreateObject("scripting.dictionary")
arr = Sheet7.UsedRange
On Error Resume Next
For i = 2 To UBound(arr)
If VBA.Left(arr(i, 4), Len(str)) = str Then
dic(arr(i, 4)) = ""
End If
Next
ComboBox1.List = dic.keys
ComboBox1.DropDown
Set dic = Nothing
Dim ob
With Sheets("Feedback")
Set r1 = .Columns(4).Find(what:=str, lookat:=xlWhole)
If Not r1 Is Nothing Then
Label13 = .Cells(r1.Row, 1)
Label14 = .Cells(r1.Row, 2)
Label15 = .Cells(r1.Row, 3)
Label16 = .Cells(r1.Row, 5)
Label17 = .Cells(r1.Row, 6)
Label18 = .Cells(r1.Row, 7)
Label19 = .Cells(r1.Row, 8)
Label20 = .Cells(r1.Row, 9)
Label21 = .Cells(r1.Row, 10)

Else
Label13 = ""
Label14 = ""
Label15 = ""
Label16 = ""
Label17 = ""
Label18 = ""
Label19 = ""
Label20 = ""
Label21 = ""

End If
End With
End Sub
展开
 我来答
太极健1969
2013-01-19 · TA获得超过9029个赞
知道大有可为答主
回答量:8668
采纳率:69%
帮助的人:3532万
展开全部
Dim str$
str = ComboBox1.Text'combobox1赋值给变量str
Dim dic, arr, i As Integer
Set dic = CreateObject("scripting.dictionary")‘声明一个字典变量
arr = Sheet7.UsedRange'把sheet7表的数据赋值给数组arr
On Error Resume Next’遇到错误执行下一步
For i = 2 To UBound(arr)'在数组中循环
If VBA.Left(arr(i, 4), Len(str)) = str Then'判断数组中第4列数据中前面算起与str字符相同的字段是否与str相同
dic(arr(i, 4)) = ""'添加到字典中
End If
Next
ComboBox1.List = dic.keys‘把字典的key值赋值给combobox1列表
ComboBox1.DropDown'键盘向下方向键
后面就是判断,不详述了,
请别再接问下面的代码意思。谢谢
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式