Home > Software engineering >  As a variable, it is necessary to develop area, use the find function to find the corresponding cont
As a variable, it is necessary to develop area, use the find function to find the corresponding cont

Time:09-22

 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 Range

If TextBox6. Text="" Then
MsgBox "please enter the need to find the material models!"

The Else
Word1="material code"
Set d0=xls3. Range (" a2: t65536 "). The Find (word1, lookat:=xlWhole) 'table xls3 is already open the table, as global variables being
If Not do Is Nothing Then
H0=d0. Column
MM=ChgNumToABC (h0)
End the If

Word2="MANUFACTURE P/N"
Set d1=xls3. Range (" a2: t65536 "). The Find (word2, lookat:=xlWhole)
If Not d1 Is Nothing Then
H1=d1. Column
The h2=d1. Row
End the If

STR=TextBox6. Text



Set b=xls3. Range (Cells (2, h1), Cells (65536, h1)), Find (STR, lookat:=xlPart) 'can write this sentence, is always an error, because as a variable, the need to develop area
Is Nothing If Not b Then
V=b.R ow
S=xls3. Cells (v, h1). The Value
T=xls3. Cells (v, h0). The Value
ListBox1. AddItem (t)
ListBox2. AddItem (s)

Do

The Set b=xls3. Range (Cells (2, h1), Cells (65536, h1)). FindNext '(b) the same error
TNT=b.R ow
S1=xls3. Cells (TNT, h1). The Value
T1=xls3. Cells (TNT, h0). The Value
ListBox1. AddItem (t1)
ListBox2. AddItem (s1)
Loop Until b Is Nothing Or b.R ow=v

I=0
The Do While I & lt; ListBox1. ListCount - 1
J=I + 1
The Do While j & lt;=ListBox1. ListCount - 1
If ListBox1. List (I)=ListBox1. List (j) Then
ListBox1. RemoveItem j
The Else
J=j + 1
End the If
Loop
I=I + 1
Loop
K=0
The Do While k & lt; ListBox2. ListCount - 1
L=k + 1
The Do While l & lt;=ListBox2. ListCount - 1
If ListBox2. List (k)=ListBox2. List (l) Then
ListBox2. RemoveItem l
The Else
L=l + 1
End the If
Loop
K=k + 1
Loop

End the If


MsgBox "ok!"
End the If

End Sub

CodePudding user response:

 Set b=xls3. Range (the Replace (" A2: A65536 ", "A", ChgNumToABC (h1))), Find (STR, lookat:=xlPart) 

CodePudding user response:

Cells front prefixing xls3,
The Set b=xls3. Range (xls3. Cells (2, h1), xls3. Cells (65536, h1)). The Find (STR, lookat:=xlPart)

However, can also short...
  •  Tags:  
  • VBA
  • Related