標題:
[發問]
工作表資料分類另存工作表
[打印本頁]
作者:
missbb
時間:
2024-9-15 15:29
標題:
工作表資料分類另存工作表
各位, 本人有一WORKBOOK內有資料, 需要在SORTING "地區" 和"組別" 後. 按"地區"另存新WORKSHEET, 並以"地區" 作為WORKSHEET名稱, 但下列CODE有問題, 求教問題所在:D
[attach]37887[/attach]
Sub TSsheet2()
Application.ScreenUpdating = 0
Dim rng As Range, d As Object, ws As Worksheet
Set ws = ActiveSheet
ws.AutoFilterMode = False
c = [a5].CurrentRegion.Columns.Count
Set d = CreateObject("scripting.dictionary")
Set rng = Range([a5], Cells(Cells(Rows.Count, 1).End(1).Row, c))
a = rng.Columns(3)
For i = 2 To UBound(a)
d(a(i, 1)) = ""
Next
k = d.keys
For i = 0 To UBound(k)
ws.Copy after:=Sheets(Sheets.Count)
ActiveSheet.AutoFilterMode = False
[a5].CurrentRegion.Clear
With ws
rng.AutoFilter Field:=1, Criteria1:=k(i)
.[a5].CurrentRegion.Copy [a5]
End With
ActiveSheet.Name = [A6].Value
Next
Application.ScreenUpdating = 1
With Sheets("data").Activate
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
End With
End Sub
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)