ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦bworksheet__SelectionChangeµLªk¨ú±o¥t¤@¤u§@ªíªºª«¥ó

[µo°Ý] ¦bworksheet__SelectionChangeµLªk¨ú±o¥t¤@¤u§@ªíªºª«¥ó

¦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

TEST-A1.rar (13.14 KB)

Application.Goto [telNo]
    Set mRng2 = Application.Index([telNo], , 1)

TOP

ÁÂÁ¶W¯Åª©¥D¤j¤j¡C

¤p§Ì¤Þ¥Îª©¥D¤j¤jªºindex¨ç¼Æ¤w
¯à§¹¦¨¹B§@¡C¦ý¤p§Ì¤£¤F¸Ñ
¬°¦ó¤p§Ìªº»yªk«oµLªk°Ñ·Ó¨ì
¥t¤@¤u§@ªíªºÀx¦s®æ¦ì¸m©O¡H

·PÁª©¥D¤j¤j¡C

TOP

´N¬O¥»¤u§@ªí¤]°Ñ·Ó¤£¨ì°Ú¡I

TOP

¦]¬°§AªºÀx¦s®æ¤Á´«°Ê§@¬O¦bSheet1
¥HSet mRng2 = Range("telNo").Columns(1)³o¼Ëªº¤è¦¡«ü©w½d³ò¥²¶·¥[¤W«ü©ú¤u§@ªí
Set mRng2 = Sheet2.Range("telNo").Columns(1)
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

ÁÂÁ¤G¦ìª©¥D¤j¤jªº©ú¥Ü¡C

¨º¤p§Ì©Ò¤Þ¥Îªº
Application.Goto Range("telNo")
ªº»yªk¤]´N²@µL§@¥Î¡C¦]¦¹µLªk«ü©w¨ì¦¹
©w¸q½d³ò¤º¤F¶Ü¡H

TOP

©w¸q¦WºÙªº¤Þ¥Î­Y¨Ï¥Î¤¤¬A¸¹´N¬Oª½±µ¤Þ¥Î¦WºÙ
¥ÎRange´N³Qµø¬°Àx¦s®æ¡A­Y¦b¤£¦P¤u§@ªí¤Þ¥Î´N¥²¶·«ü¦W¤u§@ªí
¦]¬°¦b§@¥Î¤¤¤u§@ªí¤º¨ÃµL¥H¸Ó¦WºÙ©R¦Wªº°Ï°ì
§A¸ÕµÛ°µ°µ¬Ý
1.¿ï¨úSheet1ªºA1:A20¡A¦WºÙ¤è¶ô¿é¤JRng¡A«öenter
2.¦bSheet2¼Ò²Õ¿é¤J
  1. Sub nn()
  2. MsgBox [Rng].Address
  3. MsgBox Sheet1.Range("Rng").Address
  4. MsgBox Range("Rng").Address
  5. End Sub
½Æ»s¥N½X
°õ¦æµ{§Çnn¡A·|µo²{MsgBox Range("Rng").Address²£¥Í¿ù»~
3.¦bSheet1¼Ò²Õ¿é¤J
  1. Sub yy()
  2. MsgBox Range("Rng").Address
  3. End Sub
½Æ»s¥N½X
°õ¦æyyµ{§Ç´N¯à§ä¨ì¸Ó½d³ò
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

ÁÂÁª©¥D¤j¤j¡C

ª©¥Dªºª÷¥É¨}¨¥
"¾Ç®üµL²P_¤£®¢¤U°Ý"
Åý¤p§Ìªº¦¬Ã¬§ó¥[Â×´I¡C

·P®¦¤j¤j¡I

TOP

        ÀR«ä¦Û¦b : ¤H¥Í³Ì¤jªº¦¨´N¬O±q¥¢±Ñ¤¤¯¸°_¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD