Private Sub CommandButton2_Click()
Dim str As String
Dim b, d0, d1 As Range
Dim s, t, s1, t1, h1, h0 As Long
Dim v, tnt As Long
Dim i, j, k, l, m, n As Integer
Dim wr As RangeIf TextBox6.Text = "" Then
MsgBox "请输入需要查找的物料型号!"Else
word1 = "物料代码"
Set d0 = xls3.Range("a2:t65536").Find(word1, lookat:=xlWhole) ‘表xls3为已经打开的表,作为全局变量存在
If Not d0 Is Nothing Then
h0 = d0.Column
MM = ChgNumToABC(h0)
End Ifword2 = "MANUFACTURE P/N"
Set d1 = xls3.Range("a2:t65536").Find(word2, lookat:=xlWhole)
If Not d1 Is Nothing Then
h1 = d1.Column
h2 = d1.Row
End Ifstr = TextBox6.TextSet b = xls3.Range(Cells(2, h1), Cells(65536, h1)).Find(str, lookat:=xlPart)’这句话这样写可以嘛,始终报错,因为列为变量,需要制定区域范围
If Not b Is Nothing Then
v = b.Row
s = xls3.Cells(v, h1).Value
t = xls3.Cells(v, h0).Value
ListBox1.AddItem (t)
ListBox2.AddItem (s)
Do
Set b = xls3.Range(Cells(2, h1), Cells(65536, h1)).FindNext(b) ‘ 同样报错
tnt = b.Row
s1 = xls3.Cells(tnt, h1).Value
t1 = xls3.Cells(tnt, h0).Value
ListBox1.AddItem (t1)
ListBox2.AddItem (s1)
Loop Until b Is Nothing Or b.Row = vi = 0
Do While i < ListBox1.ListCount - 1
j = i + 1
Do While j <= ListBox1.ListCount - 1
If ListBox1.List(i) = ListBox1.List(j) Then
ListBox1.RemoveItem j
Else
j = j + 1
End If
Loop
i = i + 1
Loop
k = 0
Do While k < ListBox2.ListCount - 1
l = k + 1
Do While l <= ListBox2.ListCount - 1
If ListBox2.List(k) = ListBox2.List(l) Then
ListBox2.RemoveItem l
Else
l = l + 1
End If
Loop
k = k + 1
LoopEnd If
MsgBox "ok!"
End IfEnd Sub
Dim str As String
Dim b, d0, d1 As Range
Dim s, t, s1, t1, h1, h0 As Long
Dim v, tnt As Long
Dim i, j, k, l, m, n As Integer
Dim wr As RangeIf TextBox6.Text = "" Then
MsgBox "请输入需要查找的物料型号!"Else
word1 = "物料代码"
Set d0 = xls3.Range("a2:t65536").Find(word1, lookat:=xlWhole) ‘表xls3为已经打开的表,作为全局变量存在
If Not d0 Is Nothing Then
h0 = d0.Column
MM = ChgNumToABC(h0)
End Ifword2 = "MANUFACTURE P/N"
Set d1 = xls3.Range("a2:t65536").Find(word2, lookat:=xlWhole)
If Not d1 Is Nothing Then
h1 = d1.Column
h2 = d1.Row
End Ifstr = TextBox6.TextSet b = xls3.Range(Cells(2, h1), Cells(65536, h1)).Find(str, lookat:=xlPart)’这句话这样写可以嘛,始终报错,因为列为变量,需要制定区域范围
If Not b Is Nothing Then
v = b.Row
s = xls3.Cells(v, h1).Value
t = xls3.Cells(v, h0).Value
ListBox1.AddItem (t)
ListBox2.AddItem (s)
Do
Set b = xls3.Range(Cells(2, h1), Cells(65536, h1)).FindNext(b) ‘ 同样报错
tnt = b.Row
s1 = xls3.Cells(tnt, h1).Value
t1 = xls3.Cells(tnt, h0).Value
ListBox1.AddItem (t1)
ListBox2.AddItem (s1)
Loop Until b Is Nothing Or b.Row = vi = 0
Do While i < ListBox1.ListCount - 1
j = i + 1
Do While j <= ListBox1.ListCount - 1
If ListBox1.List(i) = ListBox1.List(j) Then
ListBox1.RemoveItem j
Else
j = j + 1
End If
Loop
i = i + 1
Loop
k = 0
Do While k < ListBox2.ListCount - 1
l = k + 1
Do While l <= ListBox2.ListCount - 1
If ListBox2.List(k) = ListBox2.List(l) Then
ListBox2.RemoveItem l
Else
l = l + 1
End If
Loop
k = k + 1
LoopEnd If
MsgBox "ok!"
End IfEnd Sub
解决方案 »
- 如何清除打开工程的列表?
- textbox控件的光标位置问题,希望高手解决!!!
- 求控件一个
- 请版主帮忙找一些sqldmo处理数据库事务复制的例子好吗?
- 打开QQ登陆窗口以后,怎么知道输入密码是否完成并成功登陆?
- 我编译的应用程序打开自己的一个form窗口,windows下面的任务栏就多出一个,可是我想不需要多出来,怎么班?
- 怎么在一台机器上调试winsock控件?
- 还是关于打印机走纸问题,都一个星期多了,这儿还是没人会解答,要崩溃了 :(
- vb中如何使文本框中的文本垂直居中?谢谢了。
- 有没有这样一个GRID,可以直接往里输入,然后存进数据库里去
- gridview 问题
- VBA读写另一个工作簿中数据的问题
Set b = xls3.Range(xls3.Cells(2, h1), xls3.Cells(65536, h1)).Find(str, lookat:=xlPart)不过,还可以简写的......