¦U¦ì¤j¤j¦n¡G
¤p§Ì·Q§Q¥ÎWorksheet_SelectionChange(ByVal Target As Range)
¤è¦¡³B²z¡A¦ý¬°¦óµLªk¨ú±o¥t¤@¤u§@ªíªºÀx¦s®æª«¥ó©O¡H
»¡©ú¦p¤U¡G
¤u§@ªí¤@¡Bsheets1("test") '¾Ç¥Í¦¨ÁZ
©w¸q¦WºÙ¡Gstudent
½d³ò¡Gc8-h20
¤u§@ªí¤G¡Bsheets1("tel") '¾Ç¥Í°ò¥»¸ê®Æ
©w¸q¦WºÙ¡GtelNo
½d³ò¡Gc8-f20
²{·Q¦b¤u§@ªí¤@ªº©w¸q¦WºÙªº²Ä¤@Äæ
ªº¿ï©w³æ¤@Àx¦s®æ®É¡A¥i¥H®Ö¹ï¤u§@ªí¤G
ªº¾Ç¥Í¸ê®Æ¬O§_¬Û¦P¡C¦p¤u§@ªí¤@ªº¸ê®Æ
¤£²Å®É¥i¦Û°Ê×¥¿¡C
¥H¤U¬O¤p§Ìªº»yªk¡A¤£ª¾¦p¦ó×¥¿¤~¥¿½T©O¡H
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim mSht1 As Worksheet
Dim mSht2 As Worksheet
Dim mRng1 As Range
Dim mRng2 As Range, mRng3 As Range
Dim mStr1$, mStr2$, mStr3$, nStr1$, nStr2$, nStr3$
Dim s1%, s2%, m1%, m2%, m3%
On Error Resume Next
If Intersect(Target, [student].Columns(1)) Then
'MsgBox Target.Address
s1 = Target.Row - [student].Row + 1
End If
Set mRng1 = Range("student")
'MsgBox mRng1.Address
mStr1 = mRng1.Cells(s1, 1)
mStr2 = mRng1.Cells(s1, 2)
mStr3 = mRng1.Cells(s1, 3)
Application.Goto Range("telNo")
Set mRng2 = Range("telNo").Columns(1) '³]©wª«¥óµL®Ä
MsgBox mRng2.Address
Set mRng3 = mRng2.Find(what:=mStr1, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlNext) '°õ¦æ¥¢±Ñ
If Not mRng3 Is Nothing Then
nStr1 = mRng3.Value
nStr2 = mRng3.Offset(, 1).Value
nStr3 = mRng3.Offset(, 2).Value
If mStr1 = nStr1 Then
If mStr2 <> nStr2 Then
m1 = m1 + 1
ElseIf mStr3 <> nStr3 Then
m2 = m2 + 1
End If
If m1 > 0 Then
Range("student").Cells(s1, 2) = nStr2
ElseIf m2 > 0 Then
Range("student").Cells(s1, 3) = nStr3
End If
End If
End If
End Sub
ÁÂÁ¦U¦ì¤j¤j |