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

[µo°Ý] VBA ¶}°_³Ì·s¤å¦r¤å¥óÀÉ ¨Ã­×§ï

¤£¦n·N«äª©¤j
§Ú¤å¦r¤å¥óÀɪº¤º®e¤£©w¤@¼Ë@@
¶]¨ì³o¸Ì³£·|¿ù»~
¸Ì­±¹Á¸Õ°_¨Ó ²Ä¤G¼Óªº»yªk¤ñ¸û¬O²z·Qªº@@
¦ý¬O­n§â²Ä¤@¦æ¦³ªÅ¥Õ®æ®³±¼
¦A±a¤JEXCEL¸Ì­±



Option Explicit
Dim xPath As String

Sub Ex()
    xPath = "d:\" 'ThisWorkbook.Path
    Ex_­×§ï³Ì·s¤å¦rÀÉ
   Workbooks.Open Latest_file(xPath)  '¶×¤JTXT¨ìEXCEL
End Sub
Sub Ex­×§ï¤å¥óÀÉ®×()
    Dim F As Object, E, AR(), i As Integer, A As Variant, xFile As String
     Dim My() As Integer
    'Set F = CreateObject("Scripting.FileSystemObject").GetFolder(ThisWorkbook.Path).Files
    Set F = CreateObject("Scripting.FileSystemObject").GetFolder("C:\Users\USER\Desktop\data").Files
    '.Files ->³o¸ê®Æ§¨¸ô®|¤¤ªº©Ò¦³ªºÀÉ®×
    ReDim AR(1 To 2, 1 To F.Count)
    For Each E In F
        If E Like "*.mea" Then     'ÀÉ®×°ÆÀɦW¬°txt
            i = i + 1
            AR(1, i) = E                        '°}¦C²Ä¤@ºû ¸m¤JÀɮצWºÙ
            AR(2, i) = CDbl(E.DateLastModified) '°}¦C²Ä¤Gºû ¸m¤J¦sÀɪº¤é´Á®É¶¡
        End If
    Next
    A = Application.WorksheetFunction.Index(AR, 2)
    xFile = AR(Application.Match(Application.Max(A), A, 0), 1)  '³Ì·s¦sÀɪºÀɮצWºÙ
    Set F = CreateObject("Scripting.FileSystemObject").OpenTextFile(xFile, 1)   '¶}±Ò¤å¥óÀÉ,Ū¨ú¼Ò¦¡
    A = Split(F.ReadAll, vbLf)         'Ū¨úÀɮפº®e
    F.Close                            'Ãö³¬¤å¥óÀÉ®×
    Set F = CreateObject("Scripting.FileSystemObject").CreateTextFile(xFile, True) '¶}±Ò¤å¥óÀÉ,¥iÂл\­ì¤å¥óÀɼҦ¡
    For i = 0 To UBound(A)
         F.WriteLine (i)
    Next
    F.Close

End Sub
³o¬O¦Û¤v§ïªº ¥i¯à¤£ºÉ²z·Q-..-
data.rar (57.5 KB)

TOP

¦^´_ 11# vm3503ru8
³o¸Ì­n§ï
  1. For i = 0 To UBound(A)
  2.          F.WriteLine A(i)
  3.     Next
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¶W·PÁª©¤j ¤w¸g¥i¥H¨Ï¥Î^^

TOP

        ÀR«ä¦Û¦b : §Ñ¥\¤£§Ñ¹L¡A§Ñ«è¤£§Ñ®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD