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

[µo°Ý] ¦Û°Ê²M°£¥\¯à

¥»©«³Ì«á¥Ñ GBKEE ©ó 2017-7-29 18:15 ½s¿è

¦^´_ 2# GBKEE

¤j¤j,
½Ð«ü¾É¤@¤U,§Ú¬O­n¨Ó·½Àɦb¥¼½Æ»s¸ê®Æ¤§«e¥ý±Æ§Ç,¦ýÁ`¬O¦³¨Ç°ÝÃD
1) ¨Ó·½ÀÉ»P¥ØªºÀɦP®É¨Æ¥ý¶}±Ò,©Î¦P®É¤£­n¶}±Ò,¥¦³£µLªk°õ¦æ
2) ¥ý¶}±Ò¥ØªºÀÉ,¦A°õ¦æ¥¨¶°³o®É¥¦·|¦Û¦æ¥´¶}¨Ó·½ÀÉ,³o¼Ë´N¥i¥H§¹¥þ°õ¦æ¤]·|¥ý±Æ§Ç¦A¶K¤W.
3) §Ú­n«ç»ò­×§ïÅý¥¦§¹¥þ¥¿±`¡H
  1. Option Explicit
  2. Dim ¥ØªºÀÉ As Workbook, ¨Ó·½ÀÉ As Workbook
  3. Sub ®w¦s§ó·s()
  4.     Dim xRng As Range
  5.     File_settings ¨Ó·½ÀÉ, "®w¦s¸ê®Æªí.xlsx"
  6.     File_settings ¥ØªºÀÉ, "ERP_Data.xlsx"
  7.     Set xRng = ¨Ó·½ÀÉ.Sheets(1).UsedRange  'UsedRange->¤u§@ªí©Ò¨Ï¥Îªº½d³ò,¦pA:AA¤§«á¦A¤]¨S¸ê®Æ
  8.    
  9.     '¨Ó·½ÀɲĤ@­Ó¤u§@ªí,±Æ§Ç 1) L  2)F
  10.      With ¨Ó·½ÀÉ.Sheets(1).Range("A:AA")
  11.     .Cells.Sort Key1:=.Columns("L"), Key2:=.Columns("F"), _
  12. Header:=xlYes
  13.          xRng.Copy 'A:AA½Æ»s¨ì¥ØªºÀÉB:AB
  14.     With ¥ØªºÀÉ.Sheets("®w¦s")
  15.        .Range("B1").PasteSpecial xlPasteValues '¿ï¾Ü©Ê¶K¤W­È
  16.         
  17.         '¦Û°Ê²M°£¥ØªºÀÉ1065:1073¦C
  18.         .Range("a" & xRng.Rows.Count + 1, .Range("A1101")).Resize(, 37).Clear
  19.         End With
  20.     End With
  21.     ¨Ó·½ÀÉ.Close False '¨Ó·½ÀÉÃö³¬ÀÉ®×(¤£·|°Ý¬O§_¦sÀÉ)
  22.     ¥ØªºÀÉ.Save
  23.    
  24.     End Sub
  25. Sub File_settings(xFile As Workbook, ¤u§@­¶ As String) 'Àɮ׳]©w
  26.     Dim xPath As String
  27.     xPath = ThisWorkbook.Path & "\"
  28.     If UCase(¤u§@­¶) <> UCase("ERP_Data.XLSX") Then xPath = xPath & "FromERP\"
  29.     On Error Resume Next
  30.     Set xFile = Workbooks(¤u§@­¶)
  31.     If Err > 0 Then Set xFile = Workbooks.Open(xPath & ¤u§@­¶)
  32.     If xFile.Name = "" Then
  33.         MsgBox "½Ð¬d¬Ý " & vbLf & xPath & vbLf & "¬O§_¦³ [" & ¤u§@­¶ & "]"
  34.         End
  35.     End If
  36. End Sub
½Æ»s¥N½X

TOP

[ª©¥DºÞ²z¯d¨¥]
  • GBKEE(2017/7/28 10:49): 2# ¤w«ü¦W±Æ§Çµ{¦¡½X¥i¼g¦b¨º¸Ì

¦^´_ 2# GBKEE

¤j¤j,

¦]¬°§Ú­ì¨Óªºµ{¦¡¦³±Æ§Ç¥\¯à¡A³o­Ó·sªºµ{¦¡¨S§â¨Ó·½Àɪº±Æ§Ç¥\¯à¼g¶i¥h,
1. ¥i¥HÀ°¦£§â¥¦¥[¤W¥h¶Ü¡H
2. §ó·sµ{¦¡«á,­n§â¨Ó·½ÀÉÃö³¬.

§Ú¥»¨Ó·Q­ì¨Óªº±Æ§Ç¥\¯àª½±µ²K¤W¥h¡A¦ý¦]¬°§Aªº¼gªk¤£¦P,§Ú¥[¤W¥hªº¸Ü¥¦´N¾ã­Ó¤£¯à°õ¦æ¤F¡C

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2017-7-29 19:19 ½s¿è

¦^´_ 1# PJChen

UCaseªº¥\¯à¬O¤°»ò?
§A¾Ç²ßªº¤£°÷»{¯u,¤£À´­n¬Ý¬Ý»¡©ú

¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Dim ¥ØªºÀÉ As Workbook, ¨Ó·½ÀÉ As Workbook
  3. Sub ®w¦s§ó·s()
  4.     Dim xRng As Range
  5.     File_settings ¨Ó·½ÀÉ, "®w¦s¸ê®Æªí.xlsx"
  6.     File_settings ¥ØªºÀÉ, "ERP_Data.xlsx"
  7.     With ¨Ó·½ÀÉ.Sheets(1)
  8.         .Cells.Sort Key1:=.Columns("L"), Key2:=.Columns("F"), Header:=xlYes
  9.         Set xRng = .UsedRange  'UsedRange->¤u§@ªí©Ò¨Ï¥Îªº½d³ò,¦pA:AA¤§«á¦A¤]¨S¸ê®Æ
  10.         xRng.Copy 'A:AA½Æ»s¨ì¥ØªºÀÉB:AB
  11.     End With
  12.     With ¥ØªºÀÉ.Sheets("®w¦s")
  13.        .Range("B1").PasteSpecial xlPasteValues '¿ï¾Ü©Ê¶K¤W­È
  14.         '¦Û°Ê²M°£¥ØªºÀÉ1065:1073¦C
  15.         .Range("a" & xRng.Rows.Count + 1, .Range("A1101")).Resize(, 27).Clear
  16.     End With
  17.     ¨Ó·½ÀÉ.Close False
  18.     ¥ØªºÀÉ.Save
  19. End Sub
  20. Sub File_settings(xFile As Workbook, ¤u§@­¶ As String) 'Àɮ׳]©w
  21.     Dim xPath As String
  22.     xPath = ThisWorkbook.Path & "\"
  23.     If UCase(¤u§@­¶) <> UCase("ERP_Data.XLSX") Then xPath = xPath & "FromERP\"
  24.     On Error Resume Next
  25.     Set xFile = Workbooks(¤u§@­¶)
  26.     If Err > 0 Then Set xFile = Workbooks.Open(xPath & ¤u§@­¶)
  27.     If xFile.Name = "" Then
  28.         MsgBox "½Ð¬d¬Ý " & vbLf & xPath & vbLf & "¬O§_¦³ [" & ¤u§@­¶ & "]"
  29.         End
  30.     End If
  31. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¤£­nÀH¤ß©Ò±ý¡A­nÀH¤ß±Ð¨|¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD