- ©«¤l
- 913
- ¥DÃD
- 150
- ºëµØ
- 0
- ¿n¤À
- 1089
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- office 2019
- ¾\ŪÅv
- 50
- ©Ê§O
- ¤k
- µù¥U®É¶¡
- 2011-8-28
- ³Ì«áµn¿ý
- 2023-7-19
|
¥»©«³Ì«á¥Ñ PJChen ©ó 2017-7-25 22:36 ½s¿è
½ÐÀ°À°¦£,³oÓµ{¦¡¤w¶i¤J³Ì«á¶¥¬q´N§¹¦¨¤F...
¨Ó·½Àɦ³1064¦C
¥ØªºÀɦ³1073¦C
·í¨Ó·½Àɧ⦳¸ê®Æªº½d³òA:AA½Æ»s¨ì¥ØªºÀÉB:AB«á,¦Û°Ê²M°£¥ØªºÀÉ1065:1073¦Cªº¦r(n¯àDelete¤@¾ã¦C¦ý¤£n§R°£¦C,¦]¬°¥ØªºÀɪºACÄ椧«áÁÙ¦³¤½¦¡)
ª`·N¨Æ¶µ¡G
1. ³oÓµ{¦¡´ú¸Õ¹L¨S°ÝÃD,¥u¬O·í¥ØªºÀɸê®Æ¦h©ó¨Ó·½ÀÉ®É,§Ú§Æ±æ¼W¥[¤@¶µ²M°£"¦h¾l¸ê®Æ"ªº¥\¯à
2. ²M°£¦h¾l¸ê®Æªº¼gªk,n¯à¦Û°Ê°»´ú,¦]¬°¨Ó·½ÀɤΥتºÀɪº¸ê®ÆÀH®É·|¦³ÅÜ°Ê¡A©Ò¥H¤£¯à¥ÎDelete ²Ä?¦C:²Ä?¦Cªº¼gªk
3. ¥ØªºÀɤ¤ªº1102~1104¦C¦³pºâ¤½¦¡¡A§Ú¤j¬ù³£·|Åý¥¦»P¸ê®Æ«O«ù10¦C¥H¤Wªº¶ZÂ÷,©Ò¥H½Ð§â³oÓ¤]¦Ò¶q¶i¥h,¥¦¤£¯à³QDelete
4. ½Ð¾¨¥i¯à¤£nקïì¥ýªºµ{¦¡
- Sub ®w¦s§ó·s()
- '
- '
- '
- '
- Dim Msg As Boolean, W As Workbook, Wb As Workbook 'W As "¨Ó·½ÀÉ" Wb As "¥ØªºÀÉ"
-
- 'Boolean «¬ºAªº¹w³]Ȭ° False
- '*******Workbooks ¶}±Òªº¬¡¶Ã¯ª«¥ó¶°¦X****
- For Each W In Workbooks
- If UCase(W.Name) = UCase("®w¦s¸ê®Æªí.xlsx") Then 'UCaseªº¥\¯à¬O¤°»ò?
- Msg = True 'Àɮפw¶}±Ò
- Exit For
- End If
- Next
- '*****************************************
- If Msg = True Then 'Àɮפw¶}±Ò
- Set W = Workbooks("®w¦s¸ê®Æªí.xlsx")
- Else 'Àɮש|¥¼¥´¶}®É
- Set W = Workbooks.Open("Q:\00_¬ì¼Ý\¥X³f¤å¥ó³sµ²\FromERP\®w¦s¸ê®Æªí.xlsx")
- End If
- '*****************************************
- If Msg = True Then 'Àɮפw¶}±Ò
- Set Wb = Workbooks("ERP_Data.xlsx")
- Else 'Àɮש|¥¼¥´¶}®É
- Set Wb = Workbooks.Open("Q:\00_¬ì¼Ý\¥X³f¤å¥ó³sµ²\ERP_Data.xlsx")
- End If
- '*****************************************Sorting¥H.Range("L1")¬°º
- Windows("®w¦s¸ê®Æªí.xlsx").Activate
- Range("G1").Select
- Selection.AutoFilter '«Ø¥ß¦Û°Ê¿z¿ï
- Range("G2").Select
- ActiveWindow.FreezePanes = True 'áµ²window
- 'ActiveWindow.FreezePanes = False '¨ú®øáµ²window
- With Workbooks("®w¦s¸ê®Æªí.xlsx")
- With .Sheets("®w¦s¸ê®Æªí")
- Set b = .Range("L1").CurrentRegion
- A = Array("L", "F") 'Y¦³¨ä¥LSorting¶¶¦ì¤]¥i¥[¤J
- .AutoFilter.Sort.SortFields.Clear
- For i = 0 To 1 '«üA = Array("L", "F") ¦³´XÓsorting¶µ¥Ø,2Ó´N¬O0 To 1
- .AutoFilter.Sort.SortFields.Add Key:=b.Columns(A(i)) _
- , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
- xlSortNormal
- Next
- With .AutoFilter.Sort
- .Header = xlYes
- .MatchCase = False
- .Orientation = xlTopToBottom
- .SortMethod = xlPinYin
- .Apply
- End With
- End With
- End With
- W.Save
- 'Workbooks("®w¦s¸ê®Æªí.xlsx").Close True '¦sÀÉ«áÃö³¬ÀÉ®×
-
- '*****************************************
- With W.Sheets("®w¦s¸ê®Æªí")
- Set A = Intersect(.UsedRange, .Range("A:AA")).SpecialCells(xlCellTypeVisible) '¥u¿ï¾Ü¦³¸ê®Æªº½d³ò
- End With
-
- With Wb
- 'a.Copy .Sheets("®w¦s").Range("B1") '§¹¥þ½Æ»s¨ìsheetªºB1
- '*************************************
- A.Copy
- .Sheets("®w¦s").Range("B1").PasteSpecial xlPasteValues '¿ï¾Ü©Ê¶K¤WÈ
- '*************************************
- Application.CutCopyMode = False '***¤£³B©ó°Å¤U©Î½Æ»s¼Ò¦¡
- '.Close True '¥ØªºÀɦsÀÉ«áÃö³¬ÀÉ®×
- Wb.Save '¥ØªºÀɦsÀÉ
- End With
- W.Close False '¨Ó·½ÀÉÃö³¬ÀÉ®×(¤£·|°Ý¬O§_¦sÀÉ)
- End Sub
½Æ»s¥N½X |
|