繼承人的快速程序,讓你開始...
Sub CopyColorRows()
Dim wb As Workbook
Dim shData As Worksheet
Dim shBlue As Worksheet, shGreen As Worksheet, shBlack As Worksheet
Dim rw As Range
Set wb = ActiveWorkbook
Set shData = wb.Sheets("Data")
Application.DisplayAlerts = False
On Error Resume Next
Set shBlue = wb.Sheets("Blue")
If Err.Number <> 0 Then
Err.Clear
Else
shBlue.Delete
End If
Set shBlue = wb.Sheets.Add
shBlue.Name = "Blue"
Set shGreen = wb.Sheets("Green")
If Err.Number <> 0 Then
Err.Clear
Else
shGreen.Delete
End If
Set shGreen = wb.Sheets.Add
shGreen.Name = "Green"
Set shBlack = wb.Sheets("Black")
If Err.Number <> 0 Then
Err.Clear
Else
shBlack.Delete
End If
Set shBlack = wb.Sheets.Add
shBlack.Name = "Black"
Application.DisplayAlerts = False
On Error GoTo 0
For Each rw In shData.UsedRange.Rows
Select Case rw.Cells(1, 1)
Case "Blue"
rw.Copy shBlue.UsedRange.Offset(1, 0)
Case "Green"
rw.Copy shGreen.UsedRange.Offset(1, 0)
Case "Black"
rw.Copy shBlack.UsedRange.Offset(1, 0)
End Select
Next
End Sub
沒有嚴格的編碼相關,可能屬於對http://superuser.com/ – 2011-05-04 08:27:23
這取決於你如何實施該解決方案 – Nidis 2011-05-04 08:34:25
@Gary這很可能需要一個vba解決方案,在這裏可能還行。 @ Midis這就是說,你到目前爲止嘗試過什麼,或者你只是要求某人爲你編碼? – 2011-05-04 08:38:53