Board logo

¼ÐÃD: [µo°Ý] ½Ð°Ý«e½ú­Ì ¦p¦óÅýVBA ¨Ì¾ÚÄæ¦ì¸Ìªº¦WºÙ¥h·j¯Á¨ì¦P¦WºÙªº¤u§@ªí [¥´¦L¥»­¶]

§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-2 22:22     ¼ÐÃD: ½Ð°Ý«e½ú­Ì ¦p¦óÅýVBA ¨Ì¾ÚÄæ¦ì¸Ìªº¦WºÙ¥h·j¯Á¨ì¦P¦WºÙªº¤u§@ªí

½Ð°Ý«e½ú­Ì ¦p¦óÅýVBA ¨Ì¾ÚÄæ¦ì¸Ìªº¦WºÙ¥h·j¯Á¨ì¦P¦WºÙªº¤u§@ªí
§Ú°µ¤F¤@­Ó¾P³f¨t²Î  ¦b"¾P³f³æ"¤u§@ªí¤W§¹¦¨¶ñ¼g«á «ö¤U«ü©wªº¥¨¶°
´N·|¦Û°Ê¾É¤J"¾P³f²M³æ"¤¤
°ÝÃD¨Ó¤F ¦]¬°«È¤á²£«~³£¤£¬Û¦P ©Ò¥H¶·­n§â¦U«È¤áªº¾P³f²M³æ¤À¶}
¨Ò¦p¤À¦¨¾P³f²M³æA¬°"A¤½¥q"¤u§@ªí¦WºÙ©M¾P³f²M³æB¬°"B¤½¥q"¤u§@ªí¦WºÙ
¦bA1Äæ¦ì ³]¸m¤F¸ê®ÆÅçÃÒªº²M³æ ¥i¨Ñ¿ï¾ÜA¤½¥q¡BB¤½¥q
¦p¦óÅýVBA ¨Ì¾ÚA1Äæ¦ìªº¦WºÙ ¥h·j´M¨ì©MA1Äæ¦ì¦P¦WºÙªº¤u§@ªí©O??
«ü¥O¸Ó¦p¼g©O??
«ô°U«e½ú­Ì«ü¾É«ü¾É§Ú «D±`·PÁÂ
§@ªÌ: lpk187    ®É¶¡: 2015-10-2 23:29

¥»©«³Ì«á¥Ñ lpk187 ©ó 2015-10-2 23:30 ½s¿è

¦^´_ 1# ¶¶¶Õ¦Ó¬°

¥i¥Hªº¸Ü¡A³Ì¦n¤W¶ÇÀɤW¨Ó¡A¤ñ¸û¥i¥H±o¨ì¸û¥¿½Tªºµª®×
¤£µMªº¸Ü­è¤£¤[¦V­ã¤j¾Çªº»yªk¡A®M¶i¥h§Aªºµ{¦¡¤]¦æ
       SHN =Range("A1") 'Ū¨úA1Àx¦s®æªº­È¡A(A1Äæ¦ì¦P¦WºÙªº¤u§@ªí)
      On Error Resume Next'ªí¥Ü·í¤@­Ó°õ¦æ¶¥¬q¿ù»~²£¥Í®É¡Aµ{¦¡±±¨î¥ß¨è¨ìµo¥Í¿ù»~³¯­z¦¡±µ¤U¥hªº³¯­z¦¡
     Set xS = Sheets(SHN) '³]©w xS ¬°´M§äªº¤u§@ªí ¦pªG§ä¤£¨ì·|²£¥Í¿ù»~¡A©Ò¥H­n¦³¤W¤@¥y©M¤U¤@¥y
     On Error GoTo 0 '°±¤î²{¦bµ{§ÇùØ¥ô¦ó¤w±Ò°Êªº¿ù»~³B²zµ{¦¡
µM«á«á­±
With xS      'xS=Sheets("A¤½¥q")
      ...  
      ...
End With
¥H¤W¶È¨Ñ°Ñ¦Ò
§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-3 00:04

¦^´_ 2# lpk187


    ÁÂÁ«e½úÄ@·N«ü¾É
¥H¶Ç¤Wªþ¥ó ¥u¬OA1Äæ¦ìÅܦ¨¦bO14  ¨Ï¥Îªº¥¨¶°¬O"¾É¤J"  «ô°U«e½úÀ°À°§Ú ªü¬°¥Ñ°J·PÁÂ
§@ªÌ: lpk187    ®É¶¡: 2015-10-3 01:10

¦^´_ 3# ¶¶¶Õ¦Ó¬°

¦Ò¼{§A¤£¯à¤U¸üÀɮסA©Ò¥H¥uPO¤Wµ{¦¡½X¡A½Ð¦Û¦æ´«´«¸m
­ì¨Óªºµ{¦¡¡A¤j³¡¥÷§R°£±¼¤F¡A¶â¡I¤Óªø¤F¡I°}¦C¦p¦¹¨Ï¥Î¡A·|²Ö¦º¤Hªº¡A©Ò¥H§Ú§â¥¦§ï±¼¤F
  1. Sub ¾É¤J()

  2. With Sheets("¾P³f³æ")
  3.     If .[B12] = "" Then MsgBox "½Ð¿é¤J¸ê®Æ«á¦A«ö«ö¶s ": Exit Sub
  4.     shN = .[O14]
  5.     Ro = .[B27].End(xlUp).Row
  6.     arr = .Range("C12:I" & Ro)
  7.     ¤é´Á = .[h7]
  8. End With
  9. On Error Resume Next 'ªí¥Ü·í¤@­Ó°õ¦æ¶¥¬q¿ù»~²£¥Í®É¡Aµ{¦¡±±¨î¥ß¨è¨ìµo¥Í¿ù»~³¯­z¦¡±µ¤U¥hªº³¯­z¦¡
  10. Set xS = Sheets(shN) '³]©w xS ¬°´M§äªº¤u§@ªí ¦pªG§ä¤£¨ì·|²£¥Í¿ù»~¡A©Ò¥H­n¦³¤W¤@¥y©M¤U¤@¥y
  11. On Error GoTo 0 '°±¤î²{¦bµ{§ÇùØ¥ô¦ó¤w±Ò°Êªº¿ù»~³B²zµ{¦¡
  12. With xS
  13.     xSro = .Cells(Rows.Count, 1).End(xlUp).Row + 1
  14.     .Cells(xSro, "B").Resize(UBound(arr, 1), UBound(arr, 2)) = arr
  15.     .Range("A" & xSro & ":A" & xSro + UBound(arr, 1) - 1) = ¤é´Á
  16. End With
  17. Sheets("¾P³f³æ").Select
  18. Range("B12:B26,D12:D26,H7:H8,H5").ClearContents
  19. Range("C4") = "S" & Format(Right(Range("C4"), 4) + 1, "0000")

  20. End Sub
½Æ»s¥N½X

§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-3 08:31

¦^´_ 4# lpk187

«e½ú¯uªº¬O¤Ó·PÁ±z¤F ,¤@¦­¿ô¨Ó³£·P°Ê¨ì§Ö¬y²´²\¤F¡C
§Úª¾¹D§Ú¨º¼Ë¼g¬O²Â³Jªº¤è¦¡,©Ò¥H¤~¤£´±®³¤W¨Ó¶Ç¡C
§Ú¬O³o1~2­Ó¤ë¤~¦Û¤v±qºô¸ô¼v¤ù¾Ç²ßªº¶W¯Åªù¥~º~
¯uªº¬OÀ°¤F§Ú¦n¤jªº¦£ªü!!ÁÂÁÂ~¸U¤À·PÁ±z
§@ªÌ: ­ã´£³¡ªL    ®É¶¡: 2015-10-3 11:17

¦^´_ 2# lpk187

'¡õ¥ÑÀx¦s®æ¨Ó«ü©w¤u§@ªí¡e¦WºÙ¡f
SHN =Range("A1")

'¡õ¡e©¿²¤¡fµ{¦¡¿ù»~¡A¡eÄ~Äò¡f©¹¤U°õ¦æ«á­±ªº«ü¥O
On Error Resume Next¡@
¡@
'¡õ³]©w xS µ¹¡e«ü©w¤u§@ªí¡f¡A¦pªG¸Ó¤u§@ªí¤£¦s¦b¡A·|²£¥Í¡e¿ù»~¨Ã¤¤Â_¡f¦b³o¤@¦æ¡A
Set xS = Sheets(SHN)¡@¡@'¦]¬°¦³¤W¤@¥y¡Aµ{¦¡¤£¤¤Â_¦Ó©¹¤U°õ¦æ

'¡õ¡e«ì´_¡fµ{¦¡¿ù»~³B²z¡A¥ç§Y On Error Resume Next ¨ì³o¦æ¥H«á´N¡e¥¢®Ä¡f¡A
'¡@¨ä«áµ{¦¡­Y¦³¿ù»~¡A¤@¼Ë·|²£¥Í¡e¤¤Â_¡f¡A¤£µM¤U¤èµ{¦¡¦³¿ù»~´NµLªkµo²{¡I
On Error GoTo 0

'¡õ©Ò¥H¡AÁÙ¬O­n¥[³o¦æ¥H¡e´£¿ô¡f¨Ï¥ÎªÌ¡A¨Ã¡e¸õÂ÷¡fµ{¦¡
If xS Is Nothing Then MsgBox "¤u§@ªí¤£¦s¦b": Exit Sub¡@¡@

'¡õ¤W¤è³£¨S°ÝÃD¡A¤~·|°õ¦æ¥H¤Uªºµ{¦¡½X¡A¥HÁקKµLªk¹wª¾ªº¿ù»~¡A³y¦¨¸ê®Æ¿ù»~
With xS      'xS=Sheets("A¤½¥q")
      ...  
End With
§@ªÌ: lpk187    ®É¶¡: 2015-10-3 11:35

¦^´_ 6# ­ã´£³¡ªL

¹ï§q¡I§Ñ°O¥[¤F¡A·PÁ­ã¤j´£¿ô¡IÁÂÁÂ
§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-3 13:57

¦^´_ 6# ­ã´£³¡ªL

­ã´£³¡ªLª©¤j: ÁÂÁ±zªºÄ_¶Q´£¿ô ,ªº½T¦³³o¤@ÂI¤p¤pªºª¬ªp ¡C
¦ý¬Oª©¤j If xS Is Nothing Then MsgBox "¤u§@ªí¤£¦s¦b": Exit Sub
³o¦æ¶K¤W¥h«á §Ú¥h°µ¤@­Ó¨S¦³¤u§@ªíªº°õ¦æ
«ü¥O¥u¶]¨ì   If xS Is Nothing Then ´N¥X²{°»¿ù¤F
¦Ó¤£·|Ä~Äò¶] MsgBox "¤u§@ªí¤£¦s¦b": Exit Sub ³o¬q¿ù»~´£¿ô
½Ð°Ý§Ú¬O­þ­Ó³¡¤À¿ù¤F??
  1. Sub ¾É¤J()
  2. Application.ScreenUpdating = False
  3. With Sheets("¾P³f³æ")

  4. If .[B12] = "" Then MsgBox "½Ð¿é¤J¸ê®Æ«á¦A«ö«ö¶s ": Exit Sub
  5.     shN = .[O14]
  6.     Ro = .[B27].End(xlUp).Row
  7.     arr = .Range("C12:I" & Ro)
  8.     ¤é´Á = .[h7]
  9. End With
  10. On Error Resume Next 'ªí¥Ü·í¤@­Ó°õ¦æ¶¥¬q¿ù»~²£¥Í®É¡Aµ{¦¡±±¨î¥ß¨è¨ìµo¥Í¿ù»~³¯­z¦¡±µ¤U¥hªº³¯­z¦¡
  11. Set xS = Sheets(shN) '³]©w xS ¬°´M§äªº¤u§@ªí ¦pªG§ä¤£¨ì·|²£¥Í¿ù»~¡A©Ò¥H­n¦³¤W¤@¥y©M¤U¤@¥y
  12. On Error GoTo 0 '°±¤î²{¦bµ{§ÇùØ¥ô¦ó¤w±Ò°Êªº¿ù»~³B²zµ{¦¡

  13. If xS Is Nothing Then MsgBox "¤u§@ªí¤£¦s¦b": Exit Sub

  14. With xS
  15.     xSro = .Cells(Rows.Count, 1).End(xlUp).Row + 1
  16.     .Cells(xSro, "B").Resize(UBound(arr, 1), UBound(arr, 2)) = arr
  17.     .Range("A" & xSro & ":A" & xSro + UBound(arr, 1) - 1) = ¤é´Á
  18. End With
  19. Sheets("¾P³f³æ").Select
  20. Range("B12:B26,D12:D26,H7:H8,H5").ClearContents
  21. Range("C4") = "S" & Format(Right(Range("C4"), 4) + 1, "0000")
  22. Range("O14").Select
  23. Application.ScreenUpdating = True
  24. End Sub
½Æ»s¥N½X

§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-3 13:58

¦^´_ 7# lpk187

¯uªº«Ü·PÁ±z~
§@ªÌ: lpk187    ®É¶¡: 2015-10-3 16:53

¦^´_ 8# ¶¶¶Õ¦Ó¬°

§A§âIf xS Is Nothing Then MsgBox "¤u§@ªí¤£¦s¦b": Exit Sub§â³o¦C©ñ¨ì
On Error GoTo 0 ¤W­±¬Ý¬Ý
§@ªÌ: ­ã´£³¡ªL    ®É¶¡: 2015-10-3 17:22

¦^´_ 8# ¶¶¶Õ¦Ó¬°


Sub ¾É¤J()
Dim xS As Worksheet¡@

¼gVBA½Ð¾i¦¨¡eÅܼơf«Å§i¡I

¶iVBE»¡©úÀÉ¡A¤F¸Ñ¤@¤U¡e°Ï°ìÅܼơf¡e¼Ò²ÕÅܼơf¡e¥þ°ìÅܼơfªº«Å§i¤è¦¡¤Î¥\¥Î¡A
¹ï¥H«á¼g½ÆÂøµ{¦¡µ´¹ï¦³¥Î¡ã¡ã
§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-4 02:44

¦^´_ 10# lpk187
ªGµM¸ò«e½ú»¡ªº¤@¼Ë ´«¨ì¤W¤@¦æ´N¥¿½T¤F:victory:
§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-4 02:45

¦^´_ 11# ­ã´£³¡ªL

ÁÂÁª©¤j §Ú·|¥h¬Ýªº ·PÁª©¤j
§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-5 12:02

¦^´_ 2# lpk187
«e½ú ¤£¦n·N«ä §Ú¤£¯à¨p°T§A ©Ò¥H¦b³o¸Ì©M§AÁpµ¸
Ãö©ó«e½ú´£ªº½ÆÂø©Ê §Ú¦Û¤v¦³·NÃÑ¨ì ¦ý§Ú¤£¬O¾Ç³o¥X¨­ªº
©Ò¥H¥u¯àµwµÛÀY¥Ö¸Õ¬Ý¬Ý
¦Ü©ó¦~«×°ÝÃD §Ú¬O¥´ºâ¥Î¥t¦sÀɮתº¤è¦¡¨Ó°µ°Ï¹j
¨Ò¦p104¦~12¤ëµ²§ô«á §Ú±NÀÉ®×¥t¦s¦¨105¦~«× µM«á¿ý»s¤@­Ó¦~«×´_Âkªº«ö¶s
±N¦U¤½¥qªº¾P³f²M³æ§R°£¦¨ªÅ¥Õ ¦A­«·s¶}©l105¦~«×
³o¼Ë¥i¦æ¶Ü??
¤£ª¾¬O§_ ¥i©M«e½ú¨p¤UÁpµ¸ ·Q¦hª¾¹D «e½ú»¡ªº¸ê®Æ®wªº¤è¦¡ ¬O«ç»ò¼Ëªº¤@­Ó¨t²Î
ÁÂÁ«e½ú!!
§@ªÌ: ¶¶¶Õ¦Ó¬°    ®É¶¡: 2015-10-5 12:12

¦^´_ 2# lpk187
§Ñ¤F©M«e½ú»¡ §A©Ò¬Ý¨ìªº1~12¤ë¥÷ªº®æ¦¡ ´N¬O¤§«eªº¤H¯d¤U¨Óªº®æ¦¡
¦ý¬O ¬O¤@¶¡«È¤á ¤@­ÓEXCELÀÉ ¦ý§Ú´N¬O¤£·Q¨C¦¸³£­n¶}¤@°ïÀÉ®× ¤~·|·Q§â¥¦¾ã¦X¦¨¤@­Óªº
«È¤áÁöµM¤£¤Ö¶¡ ¦ý¹ê»Ú¦³1~12¤ë¤À³£¦³¥s³f¬ö¿ýªº ¬ù²ö10¶¡¥ª¥k
½Ð«e½ú¦h¦h«ü±Ð




Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)