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

[µo°Ý] ÅܧóÀɦW

[µo°Ý] ÅܧóÀɦW

½Ð°Ý¤j¤j
1.¦p¦ó(·j´M)¶}±Ò"D:\AA\"¤Uªº³Ì·s¤é´ÁªºExcelÀÉ®×(.xlsm),¨ÃÅܧóÀɦW¬°Text.xlsm,
µM«áÂл\Àx¦s¨ì"D"\BB\Text.xlsm(¤£­n¦³´£¿ô¹ï¸Ü¤è¶ô,ª½±µ¦sÀÉ)
2.µM«á±N­ì"D:\AA\"©Ò¦³ÀɮקR°£

¦p¤W­z ²Ä2ÂI§R°£ÀɮװѦҽ׾¤j¤j¦p¤U¥i¥H°µ¨ì,¦ý²Ä1ÂI¤£ª¾¹D­n¦p¦ó¼g,
½ÐÀ°À°¦£

Sub ¥¨¶°1()
Dim fs
If Dir("D:\AA\*") = "" Then: MsgBox "¨SÀÉ®×": Exit Sub
Set fs = CreateObject("scripting.filesystemobject")
fs.DeleteFile "D:\AA\*"
MsgBox "Done"
End Sub

¦^´_ 1# borshun88

¤é´ÁÀɮצWºÙªº©R¦W³W«h¬°¦ó?
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 1# borshun88
DateLastModified ÄÝ©Ê ¶Ç¦^³Ì«á¤@¦¸­×§ï«ü©wÀɮשθê®Æ§¨ªº¤é´Á©M®É¶¡¡C°ßŪ¡C
À°§A§ä¨ì³Ì·s¦³­×§ïªºÀÉ®×,³Ñ¤Uªº½Ð¦Û¤v§¹¦¨
  1. Option Explicit
  2. Sub ¥¨¶°1()
  3.     Dim f As Object, FileDate(), FileName(), S As Variant
  4.     If Dir("D:\AA\*.xlsm") = "" Then: MsgBox "¨SÀÉ®×": Exit Sub
  5.     For Each f In CreateObject("scripting.filesystemobject").GetFolder("d:\AA").Files
  6.         If InStr(f, ".xlsm") Then
  7.             ReDim Preserve FileName(S)
  8.             ReDim Preserve FileDate(S)
  9.             FileName(S) = f
  10.             FileDate(S) = CDbl(f.DateLastModified)
  11.             S = S + 1
  12.         End If
  13.     Next
  14.     If S > 0 Then
  15.         S = Application.Match(Application.Max(FileDate), FileDate, 0) - 1
  16.         MsgBox FileName(S)
  17.     End If
  18.     'fs.DeleteFile "D:\AA\*"
  19.     'MsgBox "Done"
  20. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# GBKEE
Dear GBKEE
¤j¤j´£¨Ñµ{¦¡¥i¦æ,¤]§¹¥þmatch§Ú·Q­n¹F¨ìªº»Ý¨D,¤Ó·P®¦¤F
¦ý¤p§Ì¯A²¤¤£²`¹ï³o¨Çµ{¦¡¦³¨ÇÃø¥H®ø¤Æ,¥i§_¸Ô²Ó»¡©ú

    If S > 0 Then

        S = Application.Match(Application.Max(FileDate), FileDate, 0) - 1 ''''''³o¥y´NµLªk³sµ²°_¨Ó,¤×¨ä¬O¬°¦ó­n-1??

Àµ½Ð¤j¤j¦b«ü¾É¤@¤U

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-12-7 07:27 ½s¿è

¦^´_ 4# borshun88
Array ¨ç¼Æ©Ò«Ø¥ßªº°}¦C¹w³]¤U­­¥²¬°¹s
Match ¨ç¼Æ ¦p¦³¶Ç¦^¼Æ¦r  ¥²¬°1¶}©l
VBAªº»¡©ú
  1. Option Base ³¯­z¦¡
  2. ¦b¼Ò²Õ¼h¦¸¤¤¥Î¨Ó«Å§i°}¦C¯Á¤Þªº¹w³]¤U­­¡C
  3. »yªk
  4. Option Base {0 | 1}
  5. ½Ðª`·N
  6. ­Y¹w³]ªº¤U­­­È¬° 0¡A«h Option Base ³¯­z¦¡¬O¤£»Ý­nªº¡C­Y»Ý­n¨Ï¥Î®É¡A¦¹³¯­z¦¡¥²¶·¥X²{¦b¼Ò²Õ¤¤¡A¨Ã¥B¦b¥ô¦óµ{§Ç¤§«e¡COption Base ¶È¯à¦b¼Ò²ÕùØ¥X²{¤@¦¸¡A¦Ó¥B¥²¶·¦b§t¦³ºû¼Æªº°}¦C«Å§i¤§«e¡C
  7. ªþµù ¦b Dim¡BPrivate¡BPublic¡BReDim ©M Static ³¯­z¦¡¤¤¡ATo ¤l¥y´£¨Ñ¸û¨ã¼u©Êªº¤èªk¡A¨Ó±±¨î°}¦C¯Á¤Þªº½d³ò¡CµM¦Ó¡A¦pªG¤£¨Ï¥Î To ¤l¥y¨Ó©ú½Tªº³]©w¤U­­¡A«h¥i¥Î Option Base ¨Ó§ïÅܹw³]­Èªº¤U­­¬° 1¡CArray ¨ç¼Æ©Ò«Ø¥ßªº°}¦C¹w³]¤U­­¥²¬°¹s¡A¤£¨ü Option Base ©Ò¼vÅT¡C
½Æ»s¥N½X
¦pªG¦³  Option Base  1  
¨º S ´N¤£¶·´î 1

TOP

¦^´_ 5# GBKEE
¸ÑÄÀ«D±`¸ÔºÉ,¹ï°}¦C¤S¦³¦h¤@¼hªº»{ÃÑ
·P¤U¤j¤j

¦^´_ 2# Hsieh
¤]·PÁÂHsieh ¤j¤jªºÃö¤ß¦^ÂÐ

TOP

        ÀR«ä¦Û¦b : µoµÊ®ð¬Oµu¼ÈªºµoºÆ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD