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

[µo°Ý] ¥HA2Àx¦s®æ¬°ÀɦW,°µ¦¨¤p­p³øªí

[µo°Ý] ¥HA2Àx¦s®æ¬°ÀɦW,°µ¦¨¤p­p³øªí

¦³¨Ç¨BÆJµLªk¥Î¿ý»s¤è¦¡,½Ð¤j¤j­ÌÀ°¦£!!
»Ý­n°õ¦æ¥¨¶°ªº³øªí¥i¯à¦³¼Æ­Ó,©Ò¥H§Ú§Æ±æ±NÀɮצWºÙª½±µ¼Ð¥Ü¦bA2.

¥¨¶°°õ¦æªº¨BÆJ¬°:
1- a.xlsx¤w¨Æ¥ý¶}±Ò,copy(·s¼W) ³øªí.sheet«á,±N¥¦Åܦ¨¨S¦³¥ô¦ó¤½¦¡,¦sÀɬ°:©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsx,(¬°¤F¤W¶ÇÀɮפ£­n¤Ó¤j,©Ò¥H¨Æ¥ý±Na.xlsxÅܦ¨¥u¦³­È)
2- Ãö³¬­ìa.xlsx¨Ã¥B¤£­n¦sÀÉ.
3- §R°£ ©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È  A:C (¹B§@¦¸¼Æ(¥þ) /1±Ò°Ê /2±Ò°Ê )
2- ¥H"³sÄò¤é´Á "°õ¦æ¤À²Õ¤p­p",¥[Á`ªºÄæ¦ì¬O"¥Î¹q«×¼Æ" and "¨Ï¥Î®É¶¡(¤À)".
3- §R°£AÄæ:³sÄò¤é´Á
4- ÂI¿ï¤p­p¿ï¶µ2    ActiveSheet.Outline.ShowLevels RowLevels:=2 '¤p­p«á¿ï#2
5- §Æ±æ§¹¦¨«áªº³øªí,§Ú¥t©ñ¦b"§¹¦¨«áªº³øªí.sheet"¤¤.
6. ³øªí.sheetªº¸ê®Æ¨C¦¸³£¤£¬Û¦P,·íµM¦³¥i¯à¼W¥[µ§¼Æ,¥Î¿ý»sªºµLªk¦]À³¨C¦¸¤£¦Pµ§¼Æªº§@·~.

©â¤ô¾÷¼Æ¾Ú¤ÀªR³øªí.zip (30.09 KB)

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-4-26 20:52 ½s¿è

6¤£¤ÓÀ´ , §A¸Õ¬Ý¬ÝÁÙ¦³¤°»ò°ÝÃD
  1. Sub paper2()
  2.     Workbooks(ThisWorkbook.Sheets("VBA").[A2].Value).Sheets("³øªí").Range("D:K").Copy   '½Æ»sDÄæ¨ìKÄæ
  3.    
  4.     With Workbooks.Add  '·s¼W¤@ªÅ¥Õ¬¡­¶Ã¯
  5.         With .Sheets(1)
  6.             .Name = "³øªí"
  7.             .[A1].PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False  '¶K¤W­È
  8.             .[A1].PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False  '¶K¤W¨Ó·½®æ¦¡
  9.             
  10.             '¤p­p
  11.             .[A2].Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(7, 8), _
  12.                     Replace:=True, PageBreaks:=False, SummaryBelowData:=True
  13.             
  14.             .[A:A].Delete Shift:=xlToLeft       '¤p­p«á§R°£AÄæ
  15.             .Outline.ShowLevels RowLevels:=2    '¤p­p«á¿ï#2
  16.         End With
  17.         .SaveAs "D:\©â¤ô¾÷¼Æ¾Ú¤ÀªR³øªí\©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsx"  'Àx¦sÀÉ®×
  18.         .Close
  19.     End With
  20.    
  21.     'Ãö³¬ÀÉ®×
  22.     Workbooks(ThisWorkbook.Sheets("VBA").[A2].Value).Close False
  23.     ThisWorkbook.Close False
  24. End Sub
½Æ»s¥N½X
¦^´_ 1# PJChen

TOP

¦^´_ 2# stillfish00

±z¦n,

¥¨¶°Áö¥i°õ¦æ,¦ý¦³¥H¤U¤£²Å,½Ð¦AÀ°¦£¬d¬Ý.
1.  ­ìa.xlsxªº³øªí.sheet¬°¤@­Ó®æ¦¡¤w³]©w¦nªº³øªí,§Æ±æ¥i¥H±N­ìÀÉcopy¦¨·sªº,¸û¤è«K§@·~.
2.  ·sªºÀÉ  ©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsx,µLªk±N¤½¦¡Åܦ¨­È,§Ú´ú¸Õ¤F¤U,ÁÙ¬O¦³¤½¦¡. ¦p: ©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.zip      ©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.zip (9.21 KB)
3.  §Ú·Q­n§¹¦¨«áªºÀɮצp: §¹¦¨«áªº³øªí.zip       §¹¦¨«áªº³øªí.zip (9.9 KB)

TOP

  1. Sub paper2()
  2.     With Workbooks(ThisWorkbook.Sheets("VBA").[A2].Value).Sheets("³øªí")
  3.         .UsedRange.Value = .UsedRange.Value    '§ï¬°­È
  4.         .Range("A:C").Delete Shift:=xlToLeft   '§R°£A:C
  5.         
  6.         '¤p­p
  7.         .[A2].Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(7, 8), _
  8.                 Replace:=True, PageBreaks:=False, SummaryBelowData:=True
  9.         .[A:A].Delete Shift:=xlToLeft       '¤p­p«á§R°£AÄæ
  10.         .Outline.ShowLevels RowLevels:=2    '¤p­p«á¿ï#2
  11.         .SaveAs "D:\©â¤ô¾÷¼Æ¾Ú¤ÀªR³øªí\©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsx"  'Àx¦sÀÉ®×
  12.         .Parent.Close False
  13.     End With
  14.    
  15.     'Ãö³¬³øªíµ{¦¡
  16.     ThisWorkbook.Close False
  17. End Sub
½Æ»s¥N½X
¦^´_ 3# PJChen

TOP

¦^´_ 4# stillfish00

±z¦n,

²Ä2¦¸ªº­×§ï¤w¸g¥i¥H±N¥t¦sªº ©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsxÀɮפº®e§ï¬°­È,¦ý¥¦¨ÌµLªk§¹¥þ¹³ "§¹¦¨«áªº³øªí.zip" ¦P®æ¦¡(¥]§t®Ø½u),¦]¬°³o³¡¥÷µLªk¥Î¿ý»sªº(¦]¬°³øªí¸ê®Æ·|ÅܤÆ),¦pªG¦³¤Hª¾¹D«ç»ò¼g«áÄòªºµ{¦¡ªº¸Ü,¬O§_¥i¥HÀ°À°¦£?

§Ú·QÅý¤p­p§¹¦¨«á ÂI¿ï¤p­p2        .Outline.ShowLevels RowLevels:=2, ±N¥i¨£Àx¦s®æ¹º¬õ¦â²Ê®Ø½u(¸Ô¨£: "§¹¦¨«áªº³øªí.zip" )

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2013-4-29 23:33 ½s¿è

¦^´_ 5# PJChen
  1. Sub Ex()
  2. Workbooks("a.xlsx").Sheets("³øªí").Copy '§â³øªí½Æ»s¨ì·sÀÉ®×
  3. Workbooks("a.xlsx").Close 0 'Ãö³¬a.xlsx
  4. Application.DisplayAlerts = False 'Ãö³¬¹ï¸Ü¤è¶ô
  5. ActiveWorkbook.SaveAs "D:\©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsx" '±N·sÀÉÀx¦s
  6. With Workbooks("©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsx") '³øªí·sÀÉ®×
  7. With .Sheets("³øªí")
  8. .UsedRange = .UsedRange.Value '¥h°£¤½¦¡
  9. .Range("A1").CurrentRegion.Subtotal GroupBy:=4, Function:=xlSum, TotalList:=Array(10, 11), _
  10.         Replace:=True, PageBreaks:=False, SummaryBelowData:=True '¤w³sÄò¤é´Á¤À²Õ¤p­p
  11. .[A:D].Delete '§R°£A:DÄæ¦ì
  12. If .[B3] = "" Then .Rows(3).Delete
  13. With .Range("F:F").SpecialCells(xlCellTypeFormulas)
  14. .Offset(, -1) = "­p"
  15. For Each A In .Cells 'µe®Ø½u
  16.    For i = 7 To 10
  17.        A.Offset(, -1).Resize(, 3).Borders(i).Weight = xlMedium
  18.        A.Offset(, -1).Resize(, 3).Borders(i).ColorIndex = 3
  19.    Next
  20. Next
  21. End With
  22. .UsedRange = .UsedRange.Value '¥h°£¤½¦¡
  23. End With
  24. .Save
  25. End With
  26. Application.DisplayAlerts = True
  27. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 6# Hsieh

¤j¤j,

·PÁ§A¦A¦¸ªºÀ°¦£.
¥X²{¤FÂI¤p°ÝÃD,¦]¬°¨C­Ó³øªí­n°Ï¤À¦UºØ¤£¦Pªº©â¤ô¾÷,©Ò¦³·|¦³¦U¦¡¦U¼ËªºÀɦW,§Ú·Q©µ¥Î³Ìªìªº·§©À,±NÀɦW³]¦b¥H¤UªºA2Àx¦s®æ¤¤,
1)  ½Ð°Ý¦b§A¼gªºµ{¦¡¤¤,§Ú­n«ç»ò±N¥H¤Uªº¥y¤l®M¶iµ{¦¡¤¤?
    With Workbooks(ThisWorkbook.Sheets("VBA").[A2].Value).Sheets("³øªí")
2) §Ú·Q±N½u§ï¦¨³Ì²Êªº½u,¬O§_§ï³o¥y?À³¸Ó«ç»ò§ï?     For Each A In .Cells 'µe®Ø½u

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2013-5-1 00:23 ½s¿è

¦^´_ 7# PJChen
  1. Sub Ex()
  2. fs = ThisWorkbook.Sheets("VBA").[A2] 'A2¬°ÀɦW
  3. Workbooks(fs).Sheets("³øªí").Copy '§â³øªí½Æ»s¨ì·sÀÉ®×
  4. Workbooks(fs).Close 0 'Ãö³¬a.xlsx
  5. Application.DisplayAlerts = False 'Ãö³¬¹ï¸Ü¤è¶ô
  6. ActiveWorkbook.SaveAs "D:\©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsx" '±N·sÀÉÀx¦s
  7. With Workbooks("©â¤ô¾÷¼Æ¾Ú¤ÀªR_­È.xlsx") '³øªí·sÀÉ®×
  8. With .Sheets("³øªí")
  9. .UsedRange = .UsedRange.Value '¥h°£¤½¦¡
  10. .Range("A1").CurrentRegion.Subtotal GroupBy:=4, Function:=xlSum, TotalList:=Array(10, 11), _
  11.         Replace:=True, PageBreaks:=False, SummaryBelowData:=True '¤w³sÄò¤é´Á¤À²Õ¤p­p
  12. .[A:D].Delete '§R°£A:DÄæ¦ì
  13. If .[B3] = "" Then .Rows(3).Delete
  14. With .Range("F:F").SpecialCells(xlCellTypeFormulas)
  15. .Offset(, -1) = "­p"
  16. For Each A In .Cells 'µe®Ø½u
  17.    For i = 7 To 10
  18.        A.Offset(, -1).Resize(, 3).Borders(i).Weight = xlThick '®Ø½u¼e«×
  19.        A.Offset(, -1).Resize(, 3).Borders(i).ColorIndex = 3 '®Ø½uÃC¦â
  20.    Next
  21. Next
  22. End With
  23. .UsedRange = .UsedRange.Value '¥h°£¤½¦¡
  24. End With
  25. .Save
  26. End With
  27. Application.DisplayAlerts = True
  28. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 8# Hsieh

¤j¤j,
1)  ¶]¨ì³o¦æ´N¤¤¤î¤F,¦]¬°A2ªºÀx¦s®æ¥i¥H¥Î¥ô·NÀɦW,ÀɦW¤£¬O"a.xlsx"®É,¥¦´NµLªkÄ~Äò¤F,§ï¦¨¥H¤U½Ð°Ý®t§O¦b­þ¨à?
Workbooks("a.xlsx").Close 0 'Ãö³¬a.xlsx....§ï¬°Workbooks(fs).Close 0 'Ãö³¬a.xlsx  >>ok
                                                                            ....§ï¬°Workbooks("fs").Close 0 'Ãö³¬a.xlsx  >>¤£¦æ
2) ­Y¤p­p&Á`­p Äæ¦ì,§ï¬°¤p¼Æ«á2¦ì¥|±Ë¤­¤J,½Ð°Ý­n¦b­þ¦æ§ó§ï?¥[¤W¤°»òµ{¦¡?

TOP

¦^´_ 8# Hsieh

¤£¦n·N«ä,°£¤F«e­±¤G¶µ,¤Sµo²{¥t¤@­Ó°ÝÃD.
3) ­ì¨Óªº³øªí.sheet¬O¦³¤½¦¡¤Î³sµ²ªº,¬°¤F¤è«K¤W¶Ç,©Ò¥H¤½¦¡®t¤£¦h³£¥h°£¤F,¦b¦sÀÉ«e­n¥ý§â¤½¦¡Åܦ¨­È(§_«h¥þ³£¿ù»~­È),¬O§_¥[¦b³o¥y¤§«á?
¥i¬O¥¦»¡¬O"¿ù»~ªº¤Þ¥Î",§Ú§ï«ç»ò§ï?
  1. Workbooks(fs).Sheets("³øªí").Copy '§â³øªí½Æ»s¨ì·sÀÉ®×
  2. .UsedRange = .UsedRange.Value '¥h°£¤½¦¡
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¯àµ½¥Î®É¶¡ªº¤H¡A¥²¯à´x´¤¦Û¤v§V¤Oªº¤è¦V¡C
ªð¦^¦Cªí ¤W¤@¥DÃD