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

VBA ¸ê®Æ·j´M°ÝÃD

¦^´_ 8# faye59

¥Ñ©ó¬O VBA µæ³¾ªºÃö«Y, ÁöµM,¤@ª½¥H¨Ó¤]¦³¬Ý¬Ý¦U¸ô°ª¤â¦b¦¹½×¾Âªº¶K¤å,
¦p: GBKEE ª©¥D¥Î¤ßªº¦bµ{§Ç½X¤W¼g¤Wµù¸Ñ. ¤]³\,¤£¬O¦Û¤vµo¥Xªº´£°Ý, ¬Ý«á¤]¬O¦üÀ´«DÀ´.

§A©Ò¤W¸ü2½gµ{¦¡½X, ¥Ñ©ó§Úªº¹q¸£¬O­^¤å¨t²Î, ¬ÒÄݶýX.
¦b¦¹§Æ±æ§A¯à±N³o2½gµ{¦¡½X¶K¦b¯d¨¥ª©¤W.Åý§Ú¥i¥H¸ÑŪ¨Ã¦¬¤U¬ã¨s. ÁÂÁÂ!!



   



§Ú¤ß¦s°g±¦, ¦]¬°¹ï VBA ªº¤@ª¾¥b¸Ñ, ·í§Ú¦bºô¤Wµo°Ý®É, §Ú¹J¨ì¤F¤@¸s¼ö¤ßÀ°§U§Úªº¤H.

TOP

¦^´_ 10# Kubi

§A¤W¸üªº½d³òª«¥óªk, «D±`¾A¥Î.

¦pªG¥i¥H, ¥i§_À°§Ú­×§ï¥H¤U2­Ó°ÝÃD...
1)        Data (¸ê®Æ®w)¨½ªº¸ê®Æ¦pªG¬O¤é´Á¥Ñ»·¦Ü¤µ. ( 22/05/2015 -  22/05/2017) §Æ±æVB ·j´Mµ²ªG§e²{ªº¬O¥Ñ¤µ¦Ü»·.
2)        Search (·j´M) ¨½ªº Row 4 ¥i§_¼W¥[ Filter, ¤è«K¦b·j´M¦Z, ¥i¥H¶i¤@¨B¿z¿ï. (¦p: Á¦±ø, Á¦ªd, Á¦¤ù)

P/s: ¥Ñ©ó¶Ã½XªºÃö«Y, §A¤W¸üªº"¦C°}ªk¡¨§Ú¤£¯à§¹¥þªº¸ÑŪ, ¥i§_¤]½Ð§A±N¥¦¶K¦b¯d¨¥ªO¤W.  µL­­·P¿E.

TOP

¦^´_ 11# Qin


   
·j´M¸ê®Æ.xlsm
  1. Sub ·j´Mªí³æ()
  2. Dim F1, F2 As Variant
  3. F1 = Sheets("·j´M").Range("B1")
  4. Sheets("·j´M").Select
  5. Sheets("·j´M").Range([A3], [J3].End(xlDown)) = ""
  6. If F1 = "" Then

  7. MsgBox "±z¥¼¿é¤J±ø¥ó"
  8. Exit Sub
  9. End If

  10. For I = 2 To Sheets("¸ê®Æ®w").UsedRange.Rows.Count
  11. If Sheets("¸ê®Æ®w").Cells(I, 4) = F1 Or Sheets("¸ê®Æ®w").Cells(I, 6) = F1 Or Sheets("¸ê®Æ®w").Cells(I, 7) = F1 Then
  12. Worksheets("¸ê®Æ®w").Range("A" & I, "J" & I).Copy Destination:=Worksheets("·j´M").Range("A" & Application.CountA(Sheets("·j´M").Columns("A:A")) + 1)
  13. End If
  14. Next I

  15. MsgBox "±z¿é¤J" & "±ø¥ó" & "[ " & F1 & " ]" & "¦@­p" & Application.CountA(Sheets("·j´M").Columns("A:A")) - 2 & "µ§¸ê®Æ"

  16. End Sub
½Æ»s¥N½X
·j¯Á¸ê®Æ1
  1. Sub Serach()
  2. Application.DisplayAlerts = False
  3. Application.ScreenUpdating = False
  4. Dim a, b, c As String
  5. Dim f1, f2, f3 As Workbook

  6. Set f1 = Sheets("¸ê®Æ®w")
  7. Set f2 = Sheets("·j´M¸ê®Æ")
  8. a = Application.InputBox("½Ð¿é¤J¬d¸ßªº¶µ¥Ø¥N½X:1.¤½¥q 2.½s¸¹ 3.«~¦W", "¿é¤J·j´M¶µ¥Ø")
  9. b = Application.InputBox("½Ð¿é¤J¬d¸ßªº¤º®e¦WºÙ", "¿é¤J·j´M¤º®e")
  10. If a = "" Or a = False Or b = "" Or b = False Then
  11. Exit Sub
  12. Else
  13. Select Case a
  14. Case "1"
  15.     X = 3
  16. Case "2"
  17.     X = 5
  18. Case "3"
  19.     X = 6
  20. Case Else
  21. Exit Sub
  22. End Select
  23. f1.Select
  24. For Each aa In Range([A2], [A2].End(xlDown))
  25. If aa.Offset(, X) = b Then
  26.     f2.Select
  27.     n = n + 1
  28.     NextRow = Cells(Rows.Count, 2).End(xlUp).Row + 1
  29.     Cells(NextRow, 1) = n
  30.     Cells(NextRow, 2).Resize(1, 9) = aa.Offset(0, 1).Resize(1, 9).Value
  31.     Cells(NextRow, 15).Resize(1, 1) = aa.Offset(0, 0).Resize(1, 1).Value
  32. End If
  33. Next
  34. End If
  35. f2.Cells(1, 15) = "total: " & Application.CountA(f2.Range("A:A")) - 1
  36. f2.Select
  37. Application.DisplayAlerts = True
  38. Application.ScreenUpdating = True
  39. End Sub
½Æ»s¥N½X
  1. Sub clase()
  2. [A3:O60000] = ""
  3. [O1] = "total: 0"
  4. End Sub
½Æ»s¥N½X
¤@¤À§V¤O¡A¤@¤À¦¬Ã¬¡C
µo°ÝÃD«e¥i¥H¥ý·j¯Á¤º¤å¬O§_¦³¬ÛÃö½d¨Ò¡C

TOP

¦^´_ 12# Qin
Q1¡G§Æ±æVB ·j´Mµ²ªG§e²{ªº¬O¥Ñ¤µ¦Ü»·¡C
A1¡G¤w¥[¼g¤F¡A¦pªþ¥ó¡C

Q2¡G¤è«K¦b·j´M¦Z, ¥i¥H¶i¤@¨B¿z¿ï¡C
A2¡G¤£´¿¼g¹L³oºØ¤è¦¡¡AÁÙ¬O½Ð¨ä¥L«e½úÀ°¦£§a¡C

°}¦Cªºµ{¦¡½X¤w¥[µù¡A½Ð°Ñ¦Ò¡G
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2.     Dim arr     '«Å§iarr¬°ÀRºA°}¦C
  3.     Dim brr()   '«Å§ibrr¬°°ÊºA°}¦C
  4.     If Target.Count <> 1 Then Exit Sub  '°²¦pChangeªºÀx¦s®æ¼Æ¶q¤£¬O1­Óªº¸Ü°h¥Xµ{§Ç
  5.     If Intersect(Target, [B1:B3]) Is Nothing Then Exit Sub      '°²¦pChangeªºÀx¦s®æ¤£¬O¦ì©óB1:B3Àx¦s®æ¤¤ªº¥ô¤@­Óªº¸Ü°h¥Xµ{§Ç
  6.     If Target.Value = "" Then       '°²¦pChangeªºÀx¦s®æªº­È¬OªÅ­È±o¸Ü(³QUser«ö¤FDeleteÁä)®É....
  7.         Application.EnableEvents = False        '¨ú®øIJµo¨Æ¥óÁקK¦]©³¤UªºDelete¦Ó¦A¦¸Ä²µo¦¹Change¨Æ¥ó
  8.         Rows("4:" & Cells.Rows.Count).Delete    '§R°£²Ä4¦C¦Ü³Ì©³¦CªºÂ¸ê®Æ
  9.         Application.EnableEvents = True     '«ì´_IJµo¨Æ¥ó
  10.         Exit Sub    '°h¥Xµ{§Ç
  11.     End If
  12.     ar = Array(6, 7, 4)     '±N6, 7, 4µ¥ÃöÁäÄæ¦ì¦s¤Jar°}¦C¤¤
  13.     arr = Sheets("Data").Range("A2:J" & Sheets("Data").[A1].End(4).Row)     '±NData¤u§@ªí¤ºªºA2¦ÜJÄ榳¸ê®Æªº³Ì©³¦C¦s¤JarrÀRºA°}¦C¤¤
  14.     n = 0   'n­È¦s¤J0
  15.     For i = 1 To UBound(arr)    '±q1¦Ü arr 1ºûªº³Ì¤j¤U¼Ð­È§@¬°°j°é
  16.         If arr(i, ar(Target.Row - 1)) = Target.Value Then   '°²¦pÀRºA°}¦Carr¤¤ªº¦Ci¤Îar°}¦C¤¤Ä檺¸ê®Æµ¥©óChangeªºÀx¦s®æªº¸ê®Æ®É....
  17.             n = n + 1   'nªº­È¥[1
  18.             ReDim Preserve brr(1 To 10, 1 To n)     '­«·s«Å§i°ÊºA°}¦Cbrrªº¤@¡B¤Gºû¤W¡B¤U¼Ðªº¼Æ²Õ¡A¥H·Ç³Æ¦s¤J©³¤U°j°éªº¸ê®Æ
  19.             For j = 1 To 10     '¦]DataÄæ¦ìÁ`¦@¬°10Äæ¡A¦]¦¹°j°é10¦¸¨ÓŪ¨ú¸Óarr¤º²Å¦X¦Cªº¸ê®Æ¡A¦s¤J°ÊºA°}¦Cªºbrr¤º
  20.                 brr(j, n) = arr(i, j)   '±N¤W­zª¬ªp¦s¤J­È
  21.             Next j
  22.         End If
  23.     Next i
  24.     If n = 0 Then   '°²¦p¤W­z°j°é³£§ä¤£¨ì¸ê®Æ®É....
  25.         MsgBox "©ó¸ê®Æ®w¤¤¨ÃµL²Å¦X·j´M±ø¥ó¡ã", vbCritical + vbOKOnly, "½Ðª`·N"      '¼u¥X°T®§Äµ§i
  26.         Exit Sub    '°h¥Xµ{§Ç
  27.     End If
  28.     Application.EnableEvents = False    '¨ú®øIJµo¨Æ¥ó
  29.     For i = 1 To 3  '¦¹°j°é¥D­n³B²zB1:B3Àx¦s®æ¤ºªº´Ý¦s¸ê®Æ
  30.         If Cells(i, 2).Address <> Target.Address Then Cells(i, 2).Value = ""    '°²¦pB1:B3Àx¦s®æ¤º¤£¬OChangeªºÀx¦s®æ¡A«h§R°£¸ê®Æ
  31.     Next i
  32.     Application.ScreenUpdating = False      '±N¿Ã¹õ­áµ²¡A¥H´î¤Öµe­±ªº¸õ°Ê
  33.     Rows("4:" & Cells.Rows.Count).Delete    '§R°£²Ä4¦C¦Ü³Ì©³¦CªºÂ¸ê®Æ
  34.    
  35.     [A4].Resize(n, 10) = Application.Transpose(brr) '±N¦s¤Jbrrªº­ÈÂà¸m«á©ñ¤J¥HA4Àx¦s®æ®i©µn¦C¡A10Ä檺½d³ò¤º
  36.     'ª`·N¤W­±ªºTranspose¡A¦]VBA³Ì¦h¥u¯àÂà¸m65536¦C¸ê®Æ¡A¦h¤F´N·|²£¥Í¿ù»~¡A§Ú¥Îªº2010ª©¡A¤§«áªºª©¥»¬O§_¦³§ó·s¤£±o¦Óª¾¡C
  37.    
  38.     Application.ScreenUpdating = False  '¨ú®ø¿Ã¹õ­áµ²
  39.     Application.EnableEvents = True         '«ì´_IJµo¨Æ¥ó
  40. End Sub
½Æ»s¥N½X
Book1(½d³òª«¥óªk¥[±Æ§Ç).rar (20.56 KB)

TOP

¦^´_ 14# Kubi


    ¦³ºÃ°Ý, ¦A¦¸³Ò·Ð....

    Book1(½d³òª«¥óªk¥[±Æ§Ç).rar (26.15 KB)

TOP

¦^´_ 15# Qin

½Ð°Ñ¦Ò
Book1(½d³òª«¥óªk¥[±Æ§Ç)-1.rar (26.06 KB)

TOP

¦^´_ 16# Kubi


    ÁÂÁÂ....

TOP

¥»©«³Ì«á¥Ñ Qin ©ó 2018-7-19 23:19 ½s¿è

¦^´_ 16# Kubi



     ¦A¦¸³Ò·Ð..
     ·í§Ú¨Ï¥Î filter ¿z¿ï«á, ¨S¦³ÁÙ­ì, ±µ¤U¨Ó¦A·j´M¸ê®Æ, ´N·| Debug
  
     
     

TOP

¦^´_ 18# Qin

¸Õ¬Ý¬Ý
Book1(½d³òª«¥óªk¥[±Æ§Ç)-2.rar (26.14 KB)

TOP

¥»©«³Ì«á¥Ñ Qin ©ó 2018-7-22 00:06 ½s¿è

¦^´_ 19# Kubi


    ¥i¥H¤F... Thanks

TOP

        ÀR«ä¦Û¦b : µêªÅ¦³ºÉ¡D§ÚÄ@µL½a¡AµoÄ@®e©ö¦æÄ@Ãø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD