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

VBA ·í2­Ó±ø¥ó¤@¼Ë®É¡A¦Û°Ê´M§ä¿é¤J

¸Õ¸Õ¬Ý:
Private Sub CommandButton1_Click()
    Dim Lst As Integer, R As Integer
    Dim Rng As Range, MH
    Dim sh As Worksheet
    Set sh = Sheets("¥D­¶")
    Lst = sh.[A65536].End(xlUp).Row        '¨ú±o"¥D­¶"ÄæA ³Ì¤U­±«DªÅ¥Õ®æªº¦C¸¹
   
    R = 1
    Set Rng = sh.Range("A2:A" & Lst)
    MH = Application.Match(TextBox1.Value, Rng, 0)
    If Not Application.IsNumber(MH) Then GoTo 101:     '¦pªGTextBox1ªº¸ê®Æ¤£¦bAÄ椤¡÷·s¼W
    R = R + MH
    If Range("B" & R) = TextBox2.Value Then            '§_«h,¤ñ¹ïTextBox2»PBÄæ
'        If Range("C" & MH) <> "" Then GoTo 101:   '??¦pªGCÄæ«DªÅ¥Õ®æ¡÷­n¤£­n·s¼W??
        Range("C" & R) = TextBox2.Value            '§_«hCÄ欰ªÅ¥Õ®æ¡÷CÄæ=BÄæ
        Exit Sub                                   '§Y ¥q¾÷¤H­û(2)=¥q¾÷¤H­û(1)
    End If
   
    '­«ÂФW¦C°Ê§@, ª½¨ì R+1>Lst
    Do
        Set Rng = sh.Range("A" & R + 1 & ":A" & Lst)
        MH = Application.Match(TextBox1.Value, Rng, 0)
        If Not Application.IsNumber(MH) Then GoTo 101:
        R = R + MH
        If Range("B" & R) = TextBox2.Value Then
            Range("C" & R) = TextBox2.Value
            Exit Sub
        End If
    Loop Until R + 1 > Lst
101:
    '·s¼W¤@¦C¸ê®Æ
    Range("A" & Lst + 1) = TextBox1.Value
    Range("B" & Lst + 1) = TextBox2.Value
End Sub

TOP

¦^´_ 5# man65boy
©êºp, ¦Ò¼{¤[©P, Ó𦨤£«K! ©¯¦n¦³¶Wª©ªº±Ï´©!!

TOP

        ÀR«ä¦Û¦b : ¤ß¤¤±`¦sµ½¸Ñ¡B¥]®e¡B·P«ä¡Bª¾¨¬¡B±¤ºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD