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

[µo°Ý] §R°£³¡¤À¤u§@ªí

[µo°Ý] §R°£³¡¤À¤u§@ªí

§Ú§â­n§R°£ªº¤u§@ªí¦WºÙ³£©ñ¦bAÄæ
¦ý¤£ª¾¨ºùئ³¿ù,Àµ½Ð¦U¦ì°ª¤â½ç±Ð
·P¿E¤£ºÉ
  1. For Each sht In Worksheets
  2.       
  3.   For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
  4.       
  5.       If sht.name = Cells(i, 1) Then
  6.       
  7.       sht.Delete
  8.       
  9.       
  10.       End If
  11.       
  12.       Application.DisplayAlerts = False

  13.                               
  14.     Next
  15.       

  16. Next
  17.          
  18.    
  19. End Sub
½Æ»s¥N½X
123

¦^´_ 1# asch2007


³Â·Ð½Ð¸Ô­z¡Aµ{¦¡°õ¦æ«á¡A§A·Q­n§e²{ªºµ²ªG¡C

¤£µM·QÀ°¦£ªº¤H¡A¼g¥X¨Óªºµ{¦¡½X¡A¥i¯à·|¸ò§A­nªºµ²ªG¡A¦³«Ü¤j¸¨®t
§Ú«Ü²Â,©Ò¥H§Ú«Ü¥Î¤ß
¡@§Ú¾ÇÃÀ¤£ºë,¦ý§Ú´÷¨Dª¾ÃÑ

TOP

¦^´_ 1# asch2007
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex()
  3.     Dim sht As Worksheet, i As Integer
  4.     Application.DisplayAlerts = False
  5.     With ActiveWorkbook
  6.         For Each sht In .Worksheets
  7.             For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
  8.                 If sht.Name = Cells(i, 1) And .Sheets.Count > 1 Then
  9.                 '.Sheets.Count > 1 '¬¡­¶Ã¯¥²¶·¦³¤@±iªº¤u§@ªí¦s¦b.
  10.                     sht.Delete
  11.                 End If
  12.             Next
  13.         Next
  14.     End With
  15. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

[ª©¥DºÞ²z¯d¨¥]
  • GBKEE(2014/10/13 11:34): ªþ¤WÀɮ׬ݬÝ

¦^´_ 2# »k¥ú°j¯T


«Ü©êºp¨S»¡²M·¡
§Ú·Q­n§R°£¦h¾lªº¤u§@ªí¡A¦ý¤£¬O¥þ§R
­n§R°£¤u§@ªíªº¦WºÙ¡A©ñ¦b¥t¤@­Ó¤u§@ªí¤¤

§ÚÀ|¸Õ¼g¤F¤@¬qµ{¦¡¡A°õ¦æ¤¤¶¡¦³¥X¿ù
¿ù»~°T®§¡G
°õ¦æ¶¥¬q¿ù»~'424':
¦¹³B»Ý­nª«¥ó

°»¿ùµ²ªG°±¦b
If sht.name = Cells(i, 1) Then

¦ý§Ú¤£ª¾¿ù¨ºùØ
§Æ±æ¦U¦ì¤j¤j«üÂI°g¬z

·P¿E¤£ºÉ
123

TOP

¥»©«³Ì«á¥Ñ luhpro ©ó 2014-10-13 21:32 ½s¿è

¦^´_ 4# asch2007
¨º¬O¦]¬° ¦b
  sht.Delete
³o¤@¦æ®É sht ª«¥ó³Q§R±¼¤F.

¦ý¬O For Next °j°éÁÙ¬OÄ~Äò¦b°õ¦æ,
©ó¬O¶]¨ì
If sht.Name ...
³o¤@¦æ®É Sht ª«¥ó¤w¸g¤£¦s¦b©Ò¥H "§ä¤£¨ìª«¥ó".

©³¤U¨âºØ¤è¦¡³£¥i¥H¤£¦A¥X²{¦¹¿ù»~°T®§.
  1.   Application.DisplayAlerts = False
  2.   For Each sht In Worksheets
  3.     For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
  4.       If Not IsEmpty(sht) Then
  5.         If sht.Name = Cells(i, 1) Then sht.Delete
  6.       End If
  7.     Next
  8.   Next
  9.   Application.DisplayAlerts = True
½Æ»s¥N½X
  1.   Application.DisplayAlerts = False
  2.   For Each sht In Worksheets
  3.     For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
  4.       If sht.Name = Cells(i, 1) Then
  5.         sht.Delete
  6.         Exit For
  7.       End If
  8.     Next
  9.   Next
  10.   Application.DisplayAlerts = True
½Æ»s¥N½X

TOP

¦^´_ 4# asch2007
  1. Sub ex()
  2. Dim Sh As Worksheet
  3. Set d = CreateObject("Scripting.Dictionary")
  4. For Each Sh In Sheets
  5.   Set d(Sh.Name) = Sh '¼È¦s©Ò¦³¤u§@ªí
  6. Next
  7. With Sheets("¤u§@ªí1") '±ý§R°£¦W³æ¤u§@ªí
  8.   For Each a In .Range(.[A1], .Cells(.Rows.Count, 1).End(xlUp))
  9.      If d.exists(CStr(a)) = True Then d(CStr(a)).Delete '¬°¨¾¤î¥H¼Æ¦r¬°¦Wªº¤u§@ªí¡A¬G¨Ï¥ÎCstrÂন¦r¦ê
  10.   Next
  11. End With
  12. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 5# luhpro


    ·PÁÂÀ°¦£¡A´ú¸Õµ²ªG²Ä¤@­ÓÁÙ¬O¤£¦æ¡A¦ý²Ä¤G­Ó¦¨¥\¡I¡I
123

TOP

¦^´_ 6# Hsieh


´ú¸Õµ²ªGÁÙ¬O¦³°ÝÃD¡A§Ú¦A¬ã¨s¬Ý¬Ý
·PÁÂ
123

TOP

test1.zip (24.66 KB)

¸g´ú¸Õµ²ªG¥u¦³"§Rªí¤G"¦¨¥\
¨ä¥L§Ú¦A¬ã¨s¬Ý¬Ý
123

TOP

¦^´_ 9# asch2007
  1. Sub §Rªí()
  2.     Dim i As Integer, sht As Worksheet
  3.     Worksheets("§Rªí¦W³æ").Activate
  4.     Application.DisplayAlerts = False
  5.     For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
  6.         For Each sht In Worksheets
  7.             If sht.name = Cells(i, 1) Then sht.Delete
  8.         Next
  9.     Next
  10.     Application.DisplayAlerts = True
  11. End Sub
  12. Sub §Rªí2()
  13. Dim i As Integer, sht As Worksheet
  14.     Worksheets("§Rªí¦W³æ").Activate
  15.     Application.DisplayAlerts = False
  16.     For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
  17.         For Each sht In Worksheets
  18.             If sht.name = Cells(i, 1) Then
  19.                 sht.Delete
  20.                 Exit For
  21.             End If
  22.         Next
  23.     Next
  24.     Application.DisplayAlerts = True
  25. End Sub
  26. Sub §Rªí3()
  27.     Dim Sh As Worksheet, d As Object, a As Range
  28.     Set d = CreateObject("Scripting.Dictionary")
  29.     For Each Sh In Sheets
  30.         Set d(Sh.name) = Sh '¼È¦s©Ò¦³¤u§@ªí
  31.     Next
  32.     Application.DisplayAlerts = False
  33.     With Sheets("§Rªí¦W³æ") '±ý§R°£¦W³æ¤u§@ªí
  34.         For Each a In .Range(.[A1], .Cells(.Rows.Count, 1).End(xlUp))
  35.             If d.exists(CStr(a)) = True Then d(CStr(a)).Delete '¬°¨¾¤î¥H¼Æ¦r¬°¦Wªº¤u§@ªí¡A¬G¨Ï¥ÎCstrÂন¦r¦ê
  36.         Next
  37.     End With
  38.     Application.DisplayAlerts = True
  39. End Sub
  40. Sub §Rªí_EX()
  41.     Dim i As Integer
  42.     Application.DisplayAlerts = False
  43.     With Worksheets("§Rªí¦W³æ")
  44.         On Error Resume Next
  45.         For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
  46.             .Parent.Sheets(.Cells(i, 1).Value).Delete
  47.         Next
  48.         On Error GoTo 0
  49.     End With
  50.     Application.DisplayAlerts = True
  51. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¦³´¼¼z¤~¯à¤À¿ëµ½´c¨¸¥¿¡F¦³Á¾µê¤~¯à«Ø¥ß¬üº¡¤H¥Í¡C
ªð¦^¦Cªí ¤W¤@¥DÃD