Private Sub TextBox2_Change()
Sheets("基本資料").Range("L29").ClearContents
k = 0
Sheets("基本資料").Cells(1, 17) = TextBox2.Text
If TextBox2.Text = "" Then
TextBox3.Text = ""
GoTo 5
End If
Sheets("學生資料").Activate
On Error Resume Next
aam = TextBox2.Text
row1 = Sheets("學生資料").Range("A65536").End(xlUp).Row
If row1 = 1 Then Exit Sub
For i = 2 To row1
If Cells(i, 4) = aam Then
k = k + 1
GoTo 5
End If
Next
5
If k = 1 Then
TextBox2.Text = Sheets("基本資料").Cells(1, 17)
GoTo 10
Else
Exit Sub
End If
10
myform5
On Error GoTo 0
End Sub
Private Sub Button1_Click()
Call myform5
End Sub
Sub myform5()
UserForm5.Show
End Sub作者: GBKEE 時間: 2010-10-22 07:17
當userform5.TextBox1有 Change時卻沒有作用
是說TextBox1鍵入內容與前內容一有相異應該即執行程式卻無動於衷
似乎此時userform5非activate,但每一個textbox卻可keyin
(因電腦重灌,失去與GBKEE聯絡方式,[email protected])
是否下列有問題
Private Sub TextBox2_Change()
Sheets("基本資料").Range("L29").ClearContents
k = 0
Sheets("基本資料").Cells(1, 17) = TextBox2.Text
If TextBox2.Text = "" Then
TextBox3.Text = ""
GoTo 5
End If
Sheets("學生資料").Activate
On Error Resume Next
aam = TextBox2.Text
row1 = Sheets("學生資料").Range("A65536").End(xlUp).Row
If row1 = 1 Then Exit Sub
For i = 2 To row1
If Cells(i, 4) = aam Then
k = k + 1
GoTo 5
End If
Next
5
If k = 1 Then
TextBox2.Text = Sheets("基本資料").Cells(1, 17)
GoTo 10
Else
Exit Sub
End If
10
myform5
On Error GoTo 0
End Sub作者: GBKEE 時間: 2010-10-22 11:33