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

[µo°Ý] ¸ô®|»PÀɦW

[µo°Ý] ¸ô®|»PÀɦW

¤j¤j¦n,

½Ð°Ý:
1. ¥H¤U¸ô®|ªº➤¤é¯Z²z³f´«ºâªí,¦bVBA¤¤¸ô®|§â➤Åܬ°?¦ÓµLªk¶}±ÒÀÉ®×,­n¦p¦ó­×§ïµ{¦¡½X or »yªk?
2. ¦bWorkbooks("OK.xlsx")µ{¦¡¤¤,¨äÀɮצWºÙ¬OOK-  5¤ë.xlsx
¦ýÀɮצ]¬°¬O¦@¥Îªº,·|¦³¤H¥h­×§ïÀɦW,VBA·|§ä¤£¨ìÀÉ®×,¦pªG§Ú·Q¥H"OK.xlsx"¥h§ä´MÀÉ®×,¤]´N¬O§â"-  5¤ë"¬Ù²¤,½Ð°Ý»yªk­n«ç»ò¼g?
  1. Dim mFile As String, ¨Ó·½ÀÉ As Workbook, ¥ØªºÀÉ As Workbook, Sh As Worksheet, xSh As Worksheet, i As String
  2. mFile = Dir("D:\Ī¦Ë¦@¥Î\­ÜÀx¦@¥Î\?¤é¯Z²z³f´«ºâªí\108.5¤ë\OK*.XLSX") '¶}±Ò«ü©w¦WºÙ¶}ÀYªºÀÉ®×
  3. Do While mFile <> ""
  4. Workbooks.Open Filename:="D:\Ī¦Ë¦@¥Î\­ÜÀx¦@¥Î\?¤é¯Z²z³f´«ºâªí\108.5¤ë\" & mFile
  5. mFile = Dir()
  6. Loop

  7. Set ¨Ó·½ÀÉ = Workbooks("²z³f³æ_All.xlsx")
  8. Set Sh = ¨Ó·½ÀÉ.Sheets("¤ñµá¦h.OK")
  9.     Set ¥ØªºÀÉ = Workbooks("OK.xlsx")
  10.     Set xSh = ¥ØªºÀÉ.Sheets(i)
½Æ»s¥N½X

  1. Sub zz()
  2. Dim mFile As String, ¨Ó·½ÀÉ As Workbook, ¥ØªºÀÉ As Workbook, Sh As Worksheet, xSh As Worksheet, i As String
  3. Dim MyPath
  4. With Application.FileDialog(msoFileDialogFolderPicker)
  5.     .InitialFileName = "D:\Ī¦Ë¦@¥Î\­ÜÀx¦@¥Î"
  6.     .Title = "¤é¯Z²z³f´«ºâªí"
  7.     .Show
  8.     If .SelectedItems.Count Then MyPath = .SelectedItems(1) Else Exit Sub
  9. End With
  10. mFile = Dir(MyPath & "\" & "OK*.XLSX") '¶}±Ò«ü©w¦WºÙ¶}ÀYªºÀÉ®×
  11. Do While mFile <> ""
  12. Workbooks.Open Filename:=MyPath & "\" & mFile
  13. mFile = Dir()
  14. Loop
  15. Set ¨Ó·½ÀÉ = Workbooks("²z³f³æ_All.xlsx")
  16. Set Sh = ¨Ó·½ÀÉ.Sheets("¤ñµá¦h.OK")
  17.     Set ¥ØªºÀÉ = Workbooks("OK.xlsx")
  18.     Set xSh = ¥ØªºÀÉ.Sheets(i)
  19. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# ikboy

±z¦n,

§¹¾ã¸ô®|¬O³o¼Ë
"D:\Ī¦Ë¦@¥Î\­ÜÀx¦@¥Î\?¤é¯Z²z³f´«ºâªí\108.5¤ë\OK*.XLSX"
¦ý¬Y¨Ç¦r¥X¤£¨Ó,Åܦ¨?
¦Ó OK*.XLSX§Ú¤]§Æ±æ¯à¥Î¼Ò½k¦r¦ê¥h¥N´Àºë½TªºÀɦW,¥H¨¾¦³¤H­×§ïÀɦW®É¥´¤£¶}
´ú¸Õªºµ²ªG,¥u¯à¶}±Ò"­ÜÀx¦@¥Î"ªº¹ï¸Ü®Ø,¨ä¥L§ó¤U¤@¼hªº¤l¸ê®Æ§¨¤ÎÀɮ׳£µLªk¶}±Ò¡I

TOP

¥»©«³Ì«á¥Ñ PJChen ©ó 2019-5-2 23:24 ½s¿è

¦^´_ 2# ikboy

ÁÂÁ±z,
§Ú¸Õ¤F¤@¾ã±ß,²×©ó¥i¥H¥Î¤F,¸ô®|ÁÙ¬OµLªk¥Î*¨ú¥N,¦ýÁ`ºâ¥i¥H¥´¶}ÀÉ®×.
  1.     Dim mFile As String, mF As String, ¨Ó·½ÀÉ As Workbook, ¥ØªºÀÉ As Workbook, Sh As Worksheet, xSh As Worksheet, i As String

  2. Path = "D:\Ī¦Ë¦@¥Î\­ÜÀx¦@¥Î\¥þ¥x²z³f´«ºâªí\"    '¨Ó·½¸ê®Æ§¨"
  3.     mFile = Dir(Path & "*µÜº¸´I*.XLSX")          '¨Ó·½ÀɦW
  4.         Do While mFile <> ""
  5.             Application.DisplayAlerts = False       '¤@¯ë´£Äµ¥Ü°T®§Ãö³¬
  6.             Workbooks.Open Filename:=Path & mFile
  7.             mFile = Dir
  8.         Loop

  9. i = Format(Date, "D") + 1  '¥H¤é´Á³]©w§@¬°¤u§@ªíªºÅܼÆ
  10. '**********************
  11. Set ¨Ó·½ÀÉ = Workbooks("²z³f³æ_All.xlsx")
  12. Set Sh = ¨Ó·½ÀÉ.Sheets("¤ñµá¦h.µÜº¸´I")
  13.     mF = Dir(Path & "*¤­ªÑµÜ*.XLSX")
  14.     mF = Dir
  15.     Set ¥ØªºÀÉ = Workbooks(Dir(Path & "*¤­ªÑµÜ*.XLSX")) '¼Ò½kÀɦW
  16.     Set xSh = ¥ØªºÀÉ.Sheets(i)
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : °ß¨ä´L­«¦Û¤vªº¤H¡A¤~§ó«i©óÁY¤p¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD