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

[µo°Ý] ¦p¦óÂ^¨ú¥X¤£­«½Æ¦WºÙªº°}¦C?

[µo°Ý] ¦p¦óÂ^¨ú¥X¤£­«½Æ¦WºÙªº°}¦C?

¤µ¤Ñ¦³¤@­Ó°ÝÃD·Q½Ð±Ð¦U¦ì¤j¤j¡A¬O³o¼Ëªº:
§Ú¦bD¼Ñ¦³¤@¸ê®Æ§¨½Æ»s¤F¦WºÙÃþ¦üªºexcel¡A·Q¨ú¥X¤£­n¥]§t³Ì«á "-¼Æ¦r"ªº¦WºÙ¦³¨º¨Ç¡A©ñ¸m¦b¤@­Ó°}¦C¤¤:
¥d¦íÂI:
°ÝÃD1.µLªk¥Î arr(i) = sDir ¨ú¥X¦U­Óxlsx
°ÝÃD2.±µ¤U¨Ó·Q¥Îlen¦bfind"-",ºâ¥X¦ì¸mµM«á¤£ª¾¹D¸Ó§R°£­«½Æ???

javascript:;

¤£ª¾¹D¦³¨S¦³¤H¥i¥H±Ð±Ð§Ú¡A¤Q¤ÀÁÂÁÂ!

¥Ø«e:
Sub List()
Dim arr(1000)
sPath = "D:\New folder\"
sDir = Dir(sPath & "*.xlsx", vbNormal)
i = 0
Do Until LenB(sDir) = 0
arr(i) = sDir
i = i + 1
Loop
End Sub

New folder.rar (24.31 KB)

File

¦^´_ 1# ui123
  1. Option Explicit
  2. Sub List()
  3.     Dim arr(), sPath As String, sDir As String, i As Integer
  4.     'arr() °ÊºA°}¦C(¤£­­¨î°}¦Cªººû¼Æ)
  5.     sPath = "D:\New folder\"
  6.     sDir = Dir(sPath & "*.xlsx", vbNormal)
  7.     i = 0
  8.     Do While sDir <> ""   '¶Ç¦^¤@­Ó String (¦r¦ê)
  9.         ReDim Preserve arr(0 To i)  'ReDim  ­«¸m°}¦Cºû¼Æ, Preserve «O¦³­ì¨Ó°}¦Cªº¤º®e
  10.         d(Split(sDir, "#")(0)) = ""
  11.         arr(i) = sDir
  12.         sDir = Dir            '¨Ì¤W¤@¦¸ªºDir±ø¥óÄ~Äò ªºDir
  13.         i = i + 1
  14.     Loop
  15. End Sub
½Æ»s¥N½X
°ÝÃD2.±µ¤U¨Ó·Q¥Îlen¦bfind"-",ºâ¥X¦ì¸mµM«á¤£ª¾¹D¸Ó§R°£­«½Æ???
20140401-01#35-1.xlsx
20140401-01#35-223.xlsx  
½Ð»¡©ú­n§R°£­þ¤@­Ó?
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¿Ë·Rªºª©¥D¡A§Ú·Q­nÅã¥Ü arr(20140401-01#35,20140401-156#35) ´N¥i¥H¤F¡A¦ý¬O arr(i) = sDir¦n¹³·|¦C¥X©Ò¦³ªºÀɮצW¡C

¤£³Ó·P¿E.....

TOP

¦^´_ 2# GBKEE

©êºp~§Ñ°O«ö¨ì¦^´_ >""""<


¿Ë·Rªºª©¥D¡A§Ú·Q­nÅã¥Ü arr(20140401-01#35,20140401-156#35) ´N¥i¥H¤F¡A¦ý¬O arr(i) = sDir¦n¹³·|¦C¥X©Ò¦³ªºÀɮצW¡C

¤£³Ó·P¿E.....

TOP

¦^´_ 4# ui123
  1. Option Explicit
  2. Sub List()
  3.     Dim sPath As String, sDir As String, i As Integer
  4.     Dim D As Object, S As Integer
  5.     Set D = CreateObject("SCRIPTING.DICTIONARY") '¦r¨åª«¥ó
  6.     sPath = "D:\New folder\"
  7.     sDir = Dir(sPath & "*.xlsx", vbNormal)
  8.     i = 0
  9.     Do While sDir <> ""   '¶Ç¦^¤@­Ó String (¦r¦ê)
  10.         S = InStrRev(sDir, "-") - 1
  11.         If Not D.EXISTS(Mid(sDir, 1, S)) Then D(Mid(sDir, 1, S)) = ""
  12.         'D.EXISTS(key) ¦r¨åª«¥óªºkey¦s¦b¶Ç¦^ True ¤Ï¤§ ¶Ç¦^ False
  13.         sDir = Dir            '¨Ì¤W¤@¦¸ªºDir±ø¥óÄ~Äò ªºDir
  14.         i = i + 1
  15.     Loop
  16.     MsgBox Join(D.keys, vbLf)
  17. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¬Ý§O¤H¤£¶¶²´¡A¬O¦Û¤v­×¾i¤£°÷¡C
ªð¦^¦Cªí ¤W¤@¥DÃD