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

[µo°Ý] ½Ð±Ð¤£¦P¬¡­¶Ã¯¶¡ªº¤u§@ªí½Æ»s

¥»©«³Ì«á¥Ñ luhpro ©ó 2013-11-15 22:30 ½s¿è

¦^´_ 1# oao
¥H¤Uµ{¦¡¤£¥i­«½Æ°õ¦æ(·|µo¥Í SheetName ­«½Æªº¿ù»~), ³o¸Ì¨S¦³³]©w«ö¶s©ÎIJµo¦¹µ{§Çªº¾÷¨î, «ØÄ³¥H³æ³¡°õ¦æ¨ÓÆ[¹î¹B§@±¡§Î.
  1. Sub CrtSheet()
  2.   Dim lRow&
  3.   Dim sStr$
  4.   Dim rSou As Range, rTar As Range

  5.   With Workbooks.Open(ThisWorkbook.Path & "\³øªí½d¥».xls")
  6.     Set rSou = .Sheets("Sheet1").[A1] ' ¨Ó·½
  7.   End With
  8.   Set rTar = ThisWorkbook.Sheets("Sheet1").[A1] ' ¥Øªº
  9.   
  10.   With rTar.Parent ' ¥u Copy 1 ­Ó Sheet, ¤§«á§ï¥H¦¹ Sheet °µ¥Àª©
  11.     lRow = 2
  12.     sStr = .Cells(lRow, 1) & "-" & .Cells(lRow, 2)
  13.     rSou.Parent.Cells.Copy
  14.     .Activate
  15.     With ActiveWorkbook.Sheets.Add(After:=Worksheets(Worksheets.Count))
  16.       With .[A1]
  17.         .PasteSpecial
  18.         .Select ' Á×§K¾ã­Ó Sheet ³Q Select ªº±¡§Î
  19.       End With
  20.       .Name = sStr ' §ï¦W
  21.     End With
  22. Application.DisplayAlerts = False ' Ãö±¼¨t²Î½T»{¬O§_©ñ±ó¤j¶q½Æ»s¸ê®Æªº¸ß°Ý°T®§
  23.     rSou.Parent.Parent.Close False ' Ãö³¬½d¨ÒÀÉ®×
  24. Application.DisplayAlerts = True
  25.   
  26.     Set rSou = Sheets(sStr).[A1] ' ²£¥Í¨ä¥L Sheet
  27.     lRow = 3
  28.     Do While .Cells(lRow, 1) <> ""
  29.       sStr = .Cells(lRow, 1) & "-" & .Cells(lRow, 2)
  30.       rSou.Parent.Cells.Copy
  31.       .Activate
  32.       With ActiveWorkbook.Sheets.Add(After:=Worksheets(Worksheets.Count))
  33.         With .[A1]
  34.           .PasteSpecial
  35.           .Select
  36.         End With
  37.         .Name = sStr
  38.       End With
  39.       lRow = lRow + 1
  40.     Loop
  41.   End With
  42. End Sub
½Æ»s¥N½X
¤£¦P¬¡­¶Ã¯¶¡ªº¤u§@ªí½Æ»s.zip (9.15 KB)
' ¥H¤U¬O§Úªº¨Ï¥Î Excel VBA ´X¦~«áªºÆ[ÂI : (¥u¨Ï¥Î¹L Excel 2000 »P Excel 2003)
' Excel VBA ¤¤¥u¯à Dim Range ¤£¯à Dim Sheet (¹ïÀ³³æ¤@ Sheet, ¥B¾A¥Î¥ô¤@ Sheet), ¥u¯à Dim WorkSheet
' ³o¸Ì¤£±Ä¥Î WorkSheet, ¦]¬°Worksheet ¥u¯à¹ïÀ³¨ì¥Ø«eªº Sheet(Active ªº), ¤£½×§A¬A©·¤º©ñ¤°»òSheetName, ¬Æ¦Ü¨Æ¥ý Set ¹Lªº, ¥Î®É³£¬O«ü¦V¦P¤@­Ó Sheet
' ¤]¤£±Ä¥Î Sheetx , ¦]¬°¤£½×¬O Sheet1, Sheet2, Sheet3... ³£«ÜÃø¥Î, Sheet1 ¥u¯à¥Î¦b Sheets(1), ¥Î¦b¨ä¥L Sheet ´N·|µo¥Í¿ù»~
' ©Ò¥H§Ú§ï¥Î Range.Parent ¨Ó«ü¦V¯S©wªº Sheet (¦n³B¬O¥u­n¤£¬O¥Î Work¬ÛÃö«ü¥O<WorkSheet...> ©Î¬O Select ´N¤£¥Î¨Æ¥ý Activate, ·Ó¼Ë¹ïÀ³¨ì¨Æ¥ý©w¸q¦nªº Sheet)

TOP

¦^´_ 6# stillfish00
¦b Type:=Thesou ³B·|µo¥Í¿ù»~.

°Ñ·Ó 6# ¤S§ï¥X¨âºØ¤è¦¡ :
  1. Sub ³øªí()
  2.     Dim x As Long
  3.     Dim wsSou As Worksheet
  4.     Dim Thesou As String
  5.     Set wsSou = Workbooks.Open(ThisWorkbook.Path & "\³øªí½d¥».xls").Sheets(1)   '½d¥»¥u§t¤@­Ó¤u§@ªí
  6.         
  7.     Application.ScreenUpdating = False
  8.     With ThisWorkbook.Sheets("Sheet1")
  9.         For x = .[A1].End(xlDown).Row To 2 Step -1
  10.             wsSou.Copy After:=.[A1].Parent
  11.              ActiveSheet.Name = .Cells(x, 1) & .Cells(x, 2)
  12.         Next
  13.     End With
  14.     Application.ScreenUpdating = True
  15. End Sub
½Æ»s¥N½X
  1. Sub ³øªí2()
  2.     Dim x As Long
  3.     Dim rSou As Range, rTar As Range
  4.     Dim Thesou As String
  5.     Set rTar = ThisWorkbook.Sheets("Sheet1").[A1]
  6.     Set rSou = Workbooks.Open(ThisWorkbook.Path & "\³øªí½d¥».xls").Sheets("Sheet1").[A1]   '½d¥»¥u§t¤@­Ó¤u§@ªí
  7.         
  8.     Application.ScreenUpdating = False
  9.     With rTar.Parent
  10.         For x = .[A1].End(xlDown).Row To 2 Step -1
  11.             rSou.Parent.Copy After:=.Parent.Sheets(1)
  12.             ActiveSheet.Name = .Cells(x, 1) & .Cells(x, 2)
  13.         Next
  14.     End With
  15.     Application.ScreenUpdating = True
  16. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : Ä@­n¤j¡B§Ó­n°í¡B®ð­n¬X¡B¤ß­n²Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD