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

[µo°Ý] ÀɦW¤£¦P¦p¦ó§PÂ_

[µo°Ý] ÀɦW¤£¦P¦p¦ó§PÂ_

½Ð¨D¦U¦ì¤j¤jªºÀ°¦£
§Ú¦³­ÓÀɮצ­¤W·|¥h¶}°_¨ä¥LÀÉ®×¼´¸ê®Æ
¦³¤@­Ó¥~³æ¦ìªºÀɮ׬ðµM§ï¤FÀɦW
½Ð°Ý­n¦p¦óÅý¨t²Î§PÂ_§ä¤£¨ì"ÀɦWA"´N¥h§ä"ÀɦWB"

³o¬O­ì¥ýªºÀɦW"¤é´Á+ªÅ®æ+¦W"
¤»´T²§°Êªí.PNG

¤µ¤Ñ²ö¦W§ï¤FÀɦW"¤é´Á+¦W"
¤»´T²§°Êªí2.PNG

Dim T$, B$, i%
T = "\\shl-group.com\dept\MFMG\B.¦U²Õ¸ê®Æ (Team inform)\E.¥ÍºÞ²Õ (PPC group)\X.¦Û°Ê¤Æ¤u¨ã(¤Å§R)\¼Ò¨ã²§°Ê-¤»ºÖ(«æ¥ó1.9±M¥Î)\"
For i = 0 To 10
   B = Format(Date - i, "yyyy.mm.dd")
   If Dir(T & B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx") <> Empty Then GoTo i01

Next
MsgBox "§ä¤£¨ì " & Date & " ~ " & Date - 10 & " ÀÉ®×": Exit Sub
i01: Workbooks.Open filename:=T & B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx", ReadOnly:=True

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

«D±`·PÁ­㴣³¡ªL¤j¤jªº¸Ñ´b

§Ú²×©ó¬ÝÀ´­ã´£³¡ªL¤j¤j´£¨Ñªº»yªk¤F
¥H¤U¬O§Úªº»{ª¾¡A¦p¦³¿ù»~ÁٽЦU¦ì¤j¤j«ü±Ð
³o¬q»yªk¬O²¤Æ«á­±"Cells.Copy" & "Close"ªº¼gªk
«e­±±N¤£¦PªºÀɦW(¤£ºÞ"¨C¤é¼Ò¨ã²§°Ê.xlsx"«e­±¦³¨S¦³ªÅ®æ©Î_)³£³]©w¬°Set xBook¡A³o¼Ë«á­±ªº°õ¦æ³£¥u­n¼g¦¨xBook+........´N¦n
Dim T As String, B As String, i As Integer, xBook As Workbook
T = "\\shl-group.com\dept\MFMG\B.¦U²Õ¸ê®Æ (Team inform)\E.¥ÍºÞ²Õ (PPC group)\X.¦Û°Ê¤Æ¤u¨ã(¤Å§R)\¼Ò¨ã²§°Ê-¤»ºÖ(«æ¥ó1.9±M¥Î)\"
For i = 0 To 10
   B = Format(Date - i, "yyyy.mm.dd")
   If Dir(T & B & "_¨C¤é¼Ò¨ã²§°Ê.xlsx") <> "" Then
      Set xBook = Workbooks.Open(T & B & "_¨C¤é¼Ò¨ã²§°Ê.xlsx", ReadOnly:=True)
      Exit For
      
   ElseIf Dir(T & B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx") <> "" Then
      Set xBook = Workbooks.Open(T & B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx", ReadOnly:=True)
      Exit For
   End If
   
Next
If xBook Is Nothing Then MsgBox "§ä¤£¨ì¥Ø¼ÐÀÉ®×": Exit Sub
End If
xBook.Sheets("LF").Columns("A:AG").Cells.Copy
' ~ do something ~
xBook.Close 0

TOP

¦^´_ 10# cowww


    ³o¼Ë¦^´_¥Nªí¨S°ÝÃD§a!ÁÂÁ¤@°_¾Ç²ß
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 9# Andy2483

¨S¦³ªÅ¥Õ¦r¤¸
LF.PNG

TOP

¦^´_ 8# cowww


    ¤µ¤Ñ­n§ìªºÀɦW  " ¨C¤é¼Ò¨ã²§°Ê.xlsx" «e¤è¦³ªÅ¥Õ¦r¤¸¶Ü?
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

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

«D±`·PÁ­㴣³¡ªL¤j¤jªº¸Ñ´b
¦ý¬O
§ä¤£¨ìÀÉ®×­C
§ä¨B¹D.PNG
LF.PNG

TOP

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


    ÁÂÁ½׾Â,ÁÂÁ«e½ú«ü¾É
«á¾Ç¾Ç²ß¤ß±oµù¸Ñ¦p¤U,½Ð«e½ú¦A«ü±Ð



Option Explicit
Sub TEST()
Dim T$, B$, i%, xBook As Workbook
'¡ô«Å§iÅܼÆ:(T,B)¬O¦r¦êÅܼÆ,i¬Oµu¾ã¼Æ,xBook¬O¬¡­¶Ã¯ÅܼÆ
T = "\\shl-group.com\dept\MFMG\B.¦U²Õ¸ê®Æ (Team inform)\E.¥ÍºÞ²Õ (PPC group)\X.¦Û°Ê¤Æ¤u¨ã(¤Å§R)\¼Ò¨ã²§°Ê-¤»ºÖ(«æ¥ó1.9±M¥Î)\"
'¡ô¥OT³o¦r¦êÅܼƬO ¸ô®|¦r¦ê
For i = 0 To 10
'¡ô³]¶¶°j°é!i±q0¨ì 10
   B = Format(Date - i, "yyyy.mm.dd")
   '¡ô¥OB³o¦r¦êÅܼƬO ¤µ¤Ñ¤é´Á-iÅܼƫá,
   'Âà´«¬°4½X¦è¤¸¦~,2½X¤ë,2½X¤é,¤¤¶¡ÂI¶¡¹jªº¦r¦ê

   If Dir(T & B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx") <> "" Then
   '¡ô¦pªGTÅܼƳs±µBÅܼÆ,¦A³s±µ" ¨C¤é¼Ò¨ã²§°Ê.xlsx"²Õ¦¨·s¦r¦ê¬d¨ì³oÀÉ®×?
      Set xBook = Workbooks.Open(T & B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx", ReadOnly:=True)
      '¡ô¥OxBook³o¬¡­¶Ã¯ÅܼƬO³Q¥´¶}ªº,
      '³Q¥´¶}ªºTÅܼƳs±µBÅܼÆ,¦A³s±µ" ¨C¤é¼Ò¨ã²§°Ê.xlsx"²Õ¦¨·s¦r¦êªºÀÉ®×

      Exit For
      '¡ôµ²§ô°j°é
   End If
Next
If xBook Is Nothing Then MsgBox "§ä¤£¨ì¥Ø¼ÐÀÉ®×": Exit Sub
'¡ô¦pªGxBookÅܼƬO¨S¦³¸ü¤Jª«¥ó!´N¸õ¥X´£¥Üµ¡,µ²§ôµ{¦¡°õ¦æ
xBook.Sheets("LF").Columns("A:AG").Cells.Copy
'¡ôÄ~Äò¥HÅܼÆxBook«ü¦V¥Ø¼Ð¥i¥HÅýµ{¦¡Â²¼ä©öµøŪ
'~~do something ~~
xBook.Close 0
'¡ô¥OxBook¤£¦sÀÉ Ãö³¬
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¥»©«³Ì«á¥Ñ ­ã´£³¡ªL ©ó 2023-4-25 19:55 ½s¿è

Dim T$, B$, i%, xBook as workbook
T = "\\shl-group.com\dept\MFMG\B.¦U²Õ¸ê®Æ (Team inform)\E.¥ÍºÞ²Õ (PPC group)\X.¦Û°Ê¤Æ¤u¨ã(¤Å§R)\¼Ò¨ã²§°Ê-¤»ºÖ(«æ¥ó1.9±M¥Î)\"
For i = 0 To 10
   B = Format(Date - i, "yyyy.mm.dd")
   If Dir(T & B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx") <> "" Then
      set xBook=Workbooks.Open(T & B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx", ReadOnly:=True)
      exit for
Next
if xbook is nothing then MsgBox "§ä¤£¨ì¥Ø¼ÐÀÉ®×": Exit Sub
xbook.sheets("LF").Columns("A:AG").Cells.Copy
~~do something ~~
xbook.Close 0

TOP

¦^´_ 4# Andy2483


¦¨¥\¤F
«D±`·PÁÂAndy2483¤j¤jªº¸Ñ´b

TOP

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-4-25 11:51 ½s¿è

¦^´_ 3# cowww


   
On Error Resume Next
Workbooks(B & " ¨C¤é¼Ò¨ã²§°Ê.xlsx").Close
Workbooks(B & "¨C¤é¼Ò¨ã²§°Ê.xlsx").Close
On Error Goto 0

===========================
¸É¥R:
«Øij«e½ú¥ý¥i¥H¥Î¤§«á¦A¬ã¨s¦p¦ó²¤Æ,Åý§ó©öµøŪ
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

        ÀR«ä¦Û¦b : ¤H¨ÆªºÁ}Ãø»PµZ¿i¡A´N¬O¤@ºØ¦ÒÅç¡C
ªð¦^¦Cªí ¤W¤@¥DÃD