|
If mycell.Offset(0, -1) = "BOM" Then
.TextBox5 = "ERP"
.Shapes("Text Box 56").TextFrame.TextRange = ""
.Shapes("Text Box 56").TextFrame.TextRange = mycell.Offset(0, 13)
ElseIf mycell.Offset(0, -1) = "一次性采购" Then
.Shapes("Text Box 56").TextFrame.TextRange = ""
budnum = wk.countif(wk.Sheets(8).[A:A], TextBoxSearch.Text & ".?") '算出类似“QJ181060044.1”的合同号的个数
ReDim Budgetnum(budnum) '定义预算号动态字符串组
ReDim arr(budnum) '定义存储动态字符串组
Set Budgetnum(0) = wk.Sheets(8).Columns(1).Find(TextBoxSearch.Text, xlpart) '找到第一个包含“QJ181060044”字样的合同号单元格
For i = 1 To budnum - 1 '
Set Budgetnum(i) = wk.Sheets(8).Columns(1).FindNext(TextBoxSearch.Text) '找到其余包含“QJ181060044”字样的合同号
Next i
Set d = CreateObject("scripting.dictionary") '创建字典对象
For i = 0 To budnum - 1
arr(i) = Budgetnum(i).Offset(0, 2).Value '将预算号赋值给字典对象的成员
Next i
For i = 0 To UBound(arr) '在字典对象中出去重复的预算号,留下唯一值
d(arr(i)) = ""
Next i
If Not Budgetnum(0) Is Nothing Then '如果“QJ181060044”合同存在,则输出全部的预算号
.TextBox5 = d.keys
End If
End If
这一段都是我自己编的,我觉得问题可能出在动态字符串组和用字典去除重复上,求大家帮忙看看。
|
|