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

[µo°Ý] Ãö©ó"¦b­ì¸ê®ÆªíºI¨ú¯S©w¸ê®Æ¶K¨ì·ssheetªº°ÝÃD"

[µo°Ý] Ãö©ó"¦b­ì¸ê®ÆªíºI¨ú¯S©w¸ê®Æ¶K¨ì·ssheetªº°ÝÃD"

¦]¬°¼gªºµ{¦¡µLªk¶¶§Q¦¨¥\¿z¿ï«á½Æ»s¡A³£¬OÅܦ¨ªÅ¥Õ¡A©Ò¥H·Q½Ð±Ð¤j®a¡C

ªþÀÉ¡G test.rar (818.44 KB)

¸ê®Æ»¡©ú¡G
ªþÀɤºexcel¸Ìªºsheet1¬OÁp¹qªÑ»ù­ì©l¸ê®Æ¡A¥D­n¥Øªº¬O­n¿z¿ï¥X"ªÑ»ù¤j©ó10"ªº¸ê®Æ±N¨ä½Æ»s¨ì·s¼W«áªº"pick"sheet

¦Û¤w¹Á¸ÕµÛ°µ¥X¨Óªºµ{¦¡½X¦p¤U¡G

Option Explicit
Dim Flag
Dim myRow As Integer
--------------------------------
Sub addsheet()
   
    Sheets.Add
    Sheets(1).Select
    ActiveSheet.Name = "pick"
End Sub
---------------------------------
Sub Choose(k)
If Worksheets("Sheet1").Cells(k, 5).Value > 10 Then
    Flag = 1
ElseIf Worksheets("Sheet1").Cells(k, 5).Value > 5 And Worksheets("Sheet1").Cells(k, 5).Value <= 10 Then
    Flag = 0
End If
End Sub
----------------------------------
Sub CopyPaste(L, M)
Dim myStr As String

    myStr = L & ":" & L
    Rows("20:20").Select
    Selection.Copy
    Sheets("pick").Select
'    myStr = a & ":" & "M"
    Range(myStr).Select
    ActiveSheet.Paste
End Sub
---------------------------------
Sub main2()
Dim i As Integer
Dim myRange As Range
Dim myCell

Set myRange = Application.InputBox("Choose the days", Type:=8) 'À°§Ú¿ï¨ú§Ú­nªºªF¦è

addsheet '°õ¦æ¤W­z·s¼W¤u§@ªíªºµ{¦¡¡A¥i¥H°õ¦æ¤W­±¼gªº¦n´X­Ó°Æµ{¦¡¡A¥i¥HÅý¨C­Óµ{¦¡¤À¤u¦X§@¡A²Õ¦X¦b¤@°_
myRow = 1

For Each myCell In myRange '¦b§Úªºmyrange¸Ì¹ï¨C¤@­Ómycell¡A¨Ó°µ¤U­±ªº¨Æ±¡
    i = myCell.Row
        
    Flag = 0 '¤£²Å¦X§Úªº­n¨D´N¸õ¨ì¤U¤@°é¥h¬Ý¬O§_¦³²Å¦X
    Choose i 'ÀË´ú²Ä20¦æ¬O§_²Å¦X§Ú³]ªº±ø¥ó
    If Flag = 1 Then
        CopyPaste i, myRow '²Å¦X³]©w±ø¥ó¡A¶K¨ì·sªº¤u§@ªí¡A¦]¬°¤£¬O¥u¦³²Ä¤G¤Q¦æ¡A©Ò¥H­n¼g°j°é
        myRow = myRow + 1
    End If
Next
End Sub

¦^´_ 1# yagami12th

§Aªº±Ô­z¸òµ{¦¡½X·N«ä¦n¹³¤£¤@¼Ë
¦pªG¥u¬O¿z¿ïEÄæ¸ê®Æ¤j©ó10ªº¸ê®Æ¶K¨ì·s¤u§@ªí
  1. Sub Main()
  2. Dim Sh As Worksheet
  3. Application.DisplayAlerts = False
  4. For Each Sh In Sheets
  5.   If Sh.Name = "Pick" Then Sh.Delete
  6. Next
  7. Application.DisplayAlerts = True
  8. With Sheet1
  9. If .FilterMode = True Then .ShowAllData
  10. .Range("A1").CurrentRegion.AutoFilter 5, ">=10"
  11. .UsedRange.SpecialCells(xlCellTypeVisible).Copy
  12. With Sheets.Add
  13. .Name = "Pick"
  14. .Paste
  15. Application.CutCopyMode = False
  16. End With
  17. .AutoFilterMode = False
  18. End With
  19. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 2# Hsieh

ÁÂÁª©¤j¡A§Ú¦n¹³¥Î¥X¨Ó¤F¡A¦ý¦³¤@¦æ¤@ª½°£¤£¤F¿ù¡A¦p¤Uºñ¦r¦âÅé¡G
Option Explicit
Dim Flag
Dim myRow As Integer
Dim newSheet As String

Sub addsheetVer2()
Static Num As Integer

    Sheets.Add after:=Sheets(Sheets.Count) '«ü¦W¤Þ¼Æ¡A¼Æ¸ÓexcelÀɦ³´X­Ósheet©ñ¦b³Ì¥kÃä
    Sheets(Sheets.Count).Select
    ActiveSheet.Name = "pick & num"
   
    Num = Num + 1
End Sub


Sub ChooseVer2(rowChoose, sheetName As String) '­ì¥ý¥u¦³¿é¤J¦C¸¹¡A²{¦b­n¥[¤W¤u§@ªíªº¦W¦r


If Worksheets("sheetName").Cells(rowChoose, 5).Value > 10 Then
    Flag = 1 '¥u¿ï¨ú«ü©wsheetªº¸ê®Æ°µ¿z¿ï
Else
End If
End Sub


Sub CopyPasteVer2(rowCopy, rowPaste, copySheet As String, pasteSheet As String) 'copy the row rowcopy in sheet with name "2330"
Dim myStr As String                                                             'and paste to the row rowpaste in the  sheet "pick"

    Sheets("copySheet").Select

    myStr = rowCopy & ":" & rowCopy
    Rows(myStr).Select
    Selection.Copy
    Sheets("pastSheet").Select
    myStr = "A" & rowPaste
    Range(myStr).Select
    ActiveSheet.Paste

End Sub

Sub main3()
Dim i As Integer
Dim myRange As Range
Dim myCell
Dim mySheet As String


mySheet = InputBox("input the sheet name you analyze") '¿ï¾Ü¤u§@ªí

Set myRange = Application.InputBox("Choose the days", Type:=8) 'À°§Ú¿ï¨ú§Ú­n¿z¿ïªº½d³ò


addsheetVer2 '°õ¦æ¤W­z·s¼W¤u§@ªíªºµ{¦¡¡A¨C¦¸¼W¥[ªº¤£¤@¼Ë¡A¥i¥H°õ¦æ¤W­±¼gªº¦n´X­Ó°Æµ{¦¡¡A¥i¥HÅý¨C­Óµ{¦¡¤À¤u¦X§@¡A²Õ¦X¦b¤@°_
myRow = 1

For Each myCell In myRange '¦b§Úªºmyrange¸Ì¹ï¨C¤@­Ómycell¡A¨Ó°µ¤U­±ªº¨Æ±¡
    i = myCell.Row
   
   
    Flag = 0 '¤£²Å¦X§Úªº­n¨D´N¸õ¨ì¤U¤@°é¥h¬Ý¬O§_¦³²Å¦X
    ChooseVer2 i, mySheet 'ÀË´ú²Ä20¦æ¬O§_²Å¦X§Ú³]ªº±ø¥ó
    If Flag = 1 Then
        CopyPasteVer2 i, myRow, mySheet, newSheet '²Å¦X³]©w±ø¥ó¡A¶K¨ì·sªº¤u§@ªí¡A¦]¬°¤£¬O¥u¦³²Ä¤G¤Q¦æ¡A©Ò¥H­n¼g°j°é
        myRow = myRow + 1
    End If
   
Next
End Sub

TOP

¦^´_ 3# yagami12th

If Worksheets(sheetName).Cells(rowChoose, 5).Value > 10 Then
    Flag = 1 '¥u¿ï¨ú«ü©wsheetªº¸ê®Æ°µ¿z¿ï
Else
End If
End Sub
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 4# Hsieh

¤@ª½°±¦b³o¦æ°£¿ù¡AµLªk°õ¦æ¡Aµ{¦¡½XÀ³¸Ó¨S¿ù¤~¹ï¡D¡D¡D

    If Worksheets(sheetName).Cells(rowChoose, 5).Value > 10 Then
     Flag = 1 '¥u¿ï¨ú«ü©wsheetªº¸ê®Æ°µ¿z¿ï
Else
End If
End Sub

TOP

¦^´_ 4# Hsieh
¦^ª©¤j¡A§ï¦¨¥Îloop°j°é¦P¼Ë¤]¥X²{¿ù»~¡A¸Õ¤£¥X­ì¦]¡A°£¿ùµøµ¡°±¦b¤U­±ºñ¦â¦rÅ骺¦a¤è

¦pªþ¥ó¡G 4³Ì«á.rar (818.3 KB)

µ{¦¡½X¦p¤U¡G
--------------------------------
Option Explicit
Dim Flag
Dim myRow As Integer
Dim newSheet As String
---------------------------------
Sub addsheetVer2()
Static Num As Integer

    Sheets.Add after:=Sheets(Sheets.Count) '«ü¦W¤Þ¼Æ¡A¼Æ¸ÓexcelÀɦ³´X­Ósheet©ñ¦b³Ì¥kÃä
    Sheets(Sheets.Count).Select
    newSheet = "pick" & Num
    ActiveSheet.Name = newSheet
   
    Num = Num + 1
End Sub
----------------------------------------------

Sub ChooseVer2(rowChoose, sheetName As String) '­ì¥ý¥u¦³¿é¤J¦C¸¹¡A²{¦b­n¥[¤W¤u§@ªíªº¦W¦r
If Worksheets("sheetName").Cells(rowChoose, 5).Value > 10 Then
    Flag = 1 '¥u¿ï¨ú«ü©wsheetªº¸ê®Æ°µ¿z¿ï
Else: the Flag = 0

End If
End Sub
-----------------------------------------
Sub CopyPasteVer2(rowCopy, rowPaste, copySheet As String, pasteSheet As String) 'copy the row rowcopy in sheet with name "2330"
Dim myStr As String                                                             'and paste to the row rowpaste in the  sheet "pick"

    Sheets("copySheet").Select

    myStr = rowCopy & ":" & rowCopy
    Rows(myStr).Select
    Selection.Copy
    Sheets("pastSheet").Select
    myStr = "A" & rowPaste
    Range(myStr).Select
    ActiveSheet.Paste

End Sub
-------------------------------------------
Sub main4()
Dim i As Integer
Dim mySheet As String

mySheet = InputBox("input the sheet name you analyze") '¿ï¾Ü¤u§@ªí

addsheetVer2 '°õ¦æ¤W­z·s¼W¤u§@ªíªºµ{¦¡¡A¨C¦¸¼W¥[ªº¤£¤@¼Ë¡A¥i¥H°õ¦æ¤W­±¼gªº¦n´X­Ó°Æµ{¦¡¡A¥i¥HÅý¨C­Óµ{¦¡¤À¤u¦X§@¡A²Õ¦X¦b¤@°_
myRow = 1: i = 2

Do While Worksheets(mySheet).Cells(i, 1) <> ""             '¦b«ü©wªº¤u§@ªí¸Ì²Ä¤@¦æ©¹¤U±½¥u­n¤£¬OªÅ¥Õ®æ´N°õ¦æ¤U­±ªºµ{¦¡½X
   
    Flag = 0 '¤£²Å¦X§Úªº­n¨D´N¸õ¨ì¤U¤@°é¥h¬Ý¬O§_¦³²Å¦X
    ChooseVer2 i, mySheet 'ÀË´ú¬O§_²Å¦X§Ú³]ªº±ø¥ó
    If Flag = 1 Then
        CopyPasteVer2 i, myRow, mySheet, newSheet '²Å¦X³]©w±ø¥ó¡A¶K¨ì·sªº¤u§@ªí¡A¦]¬°¤£¬O¥u¦³²Ä¤G¤Q¦æ¡A©Ò¥H­n¼g°j°é
        myRow = myRow + 1
    End If
    i = i + 1
Loop
End Sub

TOP

¥»©«³Ì«á¥Ñ yagami12th ©ó 2012-2-26 22:27 ½s¿è

¦^´_ 4# Hsieh
¥ÎloopªºÀɮק令¥\¤F¡A­ì¨Ó¬O¦³¨Ç«ü©w¦WºÙ¤£¥Î¥Î"" ¥]°_¨Ó

¦pªþ¥ó¡G 4finish.rar (818.72 KB)

Option Explicit
Dim Flag
Dim myRow As Integer
Dim newSheet As String

Sub addsheetVer2()
Static Num As Integer

    Sheets.Add after:=Sheets(Sheets.Count) '«ü¦W¤Þ¼Æ¡A¼Æ¸ÓexcelÀɦ³´X­Ósheet©ñ¦b³Ì¥kÃä
    Sheets(Sheets.Count).Select
    newSheet = "pick" & Num
    ActiveSheet.Name = newSheet
   
    Num = Num + 1
End Sub


Sub ChooseVer2(rowChoose, sheetName As String) '­ì¥ý¥u¦³¿é¤J¦C¸¹¡A²{¦b­n¥[¤W¤u§@ªíªº¦W¦r


If Worksheets(sheetName).Cells(rowChoose, 5).Value > 10 Then
    Flag = 1 '¥u¿ï¨ú«ü©wsheetªº¸ê®Æ°µ¿z¿ï


End If
End Sub



Sub CopyPasteVer2(rowCopy, rowPaste, copySheet As String, pasteSheet As String) 'copy the row rowcopy in sheet with name "2330"
Dim myStr As String                                                             'and paste to the row rowpaste in the  sheet "pick"

    Sheets(copySheet).Select

    myStr = rowCopy & ":" & rowCopy
    Rows(myStr).Select
    Selection.Copy
    Sheets(pasteSheet).Select
    myStr = "A" & rowPaste
    Range(myStr).Select
    ActiveSheet.Paste

End Sub

Sub main3()
Dim i As Integer
Dim myRange As Range
Dim myCell
Dim mySheet As String


mySheet = InputBox("input the sheet name you analyze") '¿ï¾Ü¤u§@ªí

Set myRange = Application.InputBox("Choose the days", Type:=8) 'À°§Ú¿ï¨ú§Ú­n¿z¿ïªº½d³ò


addsheetVer2 '°õ¦æ¤W­z·s¼W¤u§@ªíªºµ{¦¡¡A¨C¦¸¼W¥[ªº¤£¤@¼Ë¡A¥i¥H°õ¦æ¤W­±¼gªº¦n´X­Ó°Æµ{¦¡¡A¥i¥HÅý¨C­Óµ{¦¡¤À¤u¦X§@¡A²Õ¦X¦b¤@°_
myRow = 1

For Each myCell In myRange '¦b§Úªºmyrange¸Ì¹ï¨C¤@­Ómycell¡A¨Ó°µ¤U­±ªº¨Æ±¡
    i = myCell.Row
   
   
    Flag = 0 '¤£²Å¦X§Úªº­n¨D´N¸õ¨ì¤U¤@°é¥h¬Ý¬O§_¦³²Å¦X
    ChooseVer2 i, mySheet 'ÀË´ú²Ä20¦æ¬O§_²Å¦X§Ú³]ªº±ø¥ó
    If Flag = 1 Then
        CopyPasteVer2 i, myRow, mySheet, newSheet '²Å¦X³]©w±ø¥ó¡A¶K¨ì·sªº¤u§@ªí¡A¦]¬°¤£¬O¥u¦³²Ä¤G¤Q¦æ¡A©Ò¥H­n¼g°j°é
        myRow = myRow + 1
    End If
   
Next
End Sub

Sub main4()
Dim i As Integer
Dim mySheet As String


mySheet = InputBox("input the sheet name you analyze") '¿ï¾Ü¤u§@ªí

addsheetVer2 '°õ¦æ¤W­z·s¼W¤u§@ªíªºµ{¦¡¡A¨C¦¸¼W¥[ªº¤£¤@¼Ë¡A¥i¥H°õ¦æ¤W­±¼gªº¦n´X­Ó°Æµ{¦¡¡A¥i¥HÅý¨C­Óµ{¦¡¤À¤u¦X§@¡A²Õ¦X¦b¤@°_
myRow = 1: i = 2

Do While Worksheets(mySheet).Cells(i, 1) <> "" '¦b«ü©wªº¤u§@ªí¸Ì²Ä¤@¦æ©¹¤U±½¥u­n¤£¬OªÅ¥Õ®æ´N°õ¦æ¤U­±ªºµ{¦¡½X
   
    Flag = 0 '¤£²Å¦X§Úªº­n¨D´N¸õ¨ì¤U¤@°é¥h¬Ý¬O§_¦³²Å¦X
    ChooseVer2 i, mySheet 'ÀË´ú¬O§_²Å¦X§Ú³]ªº±ø¥ó
    If Flag = 1 Then
        CopyPasteVer2 i, myRow, mySheet, newSheet '²Å¦X³]©w±ø¥ó¡A¶K¨ì·sªº¤u§@ªí¡A¦]¬°¤£¬O¥u¦³²Ä¤G¤Q¦æ¡A©Ò¥H­n¼g°j°é
        myRow = myRow + 1
    End If
    i = i + 1
Loop
End Sub

TOP

¦^´_ 2# Hsieh
ÁÂÁª©¤jªºµ{¦¡½X¡A§ÚªºÀɮצpªþ¥ó¡A¦³¿ù»~ªºµ{¦¡½X¬°¤U­±ºñ¦â¦rÅé¡G 3¥¼¦¨«~.rar (819.19 KB)

--------------------------------------------------------------------------------
Option Explicit
Dim Flag
Dim myRow As Integer
Dim newSheet As String

Sub addsheetVer2()
Static Num As Integer

    Sheets.Add after:=Sheets(Sheets.Count) '«ü¦W¤Þ¼Æ¡A¼Æ¸ÓexcelÀɦ³´X­Ósheet©ñ¦b³Ì¥kÃä
    Sheets(Sheets.Count).Select
    ActiveSheet.Name = "pick & num"
   
    Num = Num + 1
End Sub
----------------------------------------------------------------

Sub ChooseVer2(rowChoose, sheetName As String) '­ì¥ý¥u¦³¿é¤J¦C¸¹¡A²{¦b­n¥[¤W¤u§@ªíªº¦W¦r


If Worksheets(sheetName).Cells(rowChoose, 5).Value > 10 Then
    Flag = 1 '¥u¿ï¨ú«ü©wsheetªº¸ê®Æ°µ¿z¿ï
   

End If
End Sub
-------------------------------------------------------------------
Sub CopyPasteVer2(rowCopy, rowPaste, copySheet As String, pasteSheet As String) 'copy the row rowcopy in sheet with name "2330"
Dim myStr As String                                                             'and paste to the row rowpaste in the  sheet "pick"

    Sheets(copySheet).Select
    myStr = rowCopy & ":" & rowCopy
    Rows(myStr).Select
    Selection.Copy
    Sheets(pasteSheet).Select        <<<<<<<³o¸Ì¥X²{°}¦C¯Á¤Þ¿ù»~9¡A§â«_¸¹ªº¿ù»~§ó¥¿ÁÙ¬O¤@¼Ë~~
    myStr = "A" & rowPaste
    Range(myStr).Select
    ActiveSheet.Paste

End Sub
--------------------------------------------------------------------
Sub main3()
Dim i As Integer
Dim myRange As Range
Dim myCell
Dim mySheet As String


mySheet = InputBox("input the sheet name you analyze") '¿ï¾Ü¤u§@ªí

Set myRange = Application.InputBox("Choose the days", Type:=8) 'À°§Ú¿ï¨ú§Ú­n¿z¿ïªº½d³ò


addsheetVer2 '°õ¦æ¤W­z·s¼W¤u§@ªíªºµ{¦¡¡A¨C¦¸¼W¥[ªº¤£¤@¼Ë¡A¥i¥H°õ¦æ¤W­±¼gªº¦n´X­Ó°Æµ{¦¡¡A¥i¥HÅý¨C­Óµ{¦¡¤À¤u¦X§@¡A²Õ¦X¦b¤@°_
myRow = 1

For Each myCell In myRange '¦b§Úªºmyrange¸Ì¹ï¨C¤@­Ómycell¡A¨Ó°µ¤U­±ªº¨Æ±¡
    i = myCell.Row
   
   
    Flag = 0 '¤£²Å¦X§Úªº­n¨D´N¸õ¨ì¤U¤@°é¥h¬Ý¬O§_¦³²Å¦X
    ChooseVer2 i, mySheet '
    If Flag = 1 Then
        CopyPasteVer2 i, myRow, mySheet, newSheet '¦b«ü©wªº¤u§@ªí§@¿z¿ï«á¶K¹L¥h¡A²Å¦X³]©w±ø¥ó¡A¶K¨ì·sªº¤u§@ªí¡A¦]¬°¤£¬O¥u¦³²Ä¤G¤Q¦æ¡A©Ò¥H­n¼g°j°é
        myRow = myRow + 1
    End If
   
Next
End Sub

TOP

¦^´_ 8# yagami12th

¨S¦³pasteSheet¦WºÙªº¤u§@ªí
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-2-27 09:12 ½s¿è

¦^´_ 8# yagami12th
¥Î¶i¶¥¿z¿ï ²¤Æ§Aªºµ{§Ç
  1. Sub Ex()
  2. Dim MyRange As Range
  3. On Error GoTo Sh_Add
  4. Set MyRange = Application.InputBox("'¿ï¾ÜªÑ²¼¤u§@ªí¸ê®Æ¥ô¤@½d³ò", Type:=8) '¿ï¨ú¤u§@
  5. Set MyRange = MyRange.CurrentRegion
  6. With Sheets("pick & num")
  7. .Cells.Clear
  8. .[A1].Name = "CopyToRange"
  9. .[IV1:IV2].Name = "Criteria"
  10. .[IV1] = MyRange.Cells(1, 5)
  11. .[IV2] = "="">=10"""
  12. MyRange.AdvancedFilter xlFilterCopy, [Criteria], [CopyToRange], True
  13. End With
  14. Exit Sub
  15. Sh_Add:
  16. MsgBox Err
  17. If Err.Number = 9 Then
  18. With Sheets.Add(after:=Sheets(Sheets.Count))
  19. .Name = "pick & num"
  20. End With
  21. End If
  22. On Error GoTo 0
  23. Resume
  24. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤Ó¶§¥ú¤j¡B¤÷¥À®¦¤j¡B§g¤l¶q¤j¡A¤p¤H®ð¤j¡C
ªð¦^¦Cªí ¤W¤@¥DÃD