标签:需要 row 完成 可见 int sel 工作表 app end
Sub shishi() Dim k, i, j As Integer Dim sht As Worksheet For i = 1 To Sheet1.Range("a65536").End(xlUp).Row k = 0 ‘事件赋值 用于发生于不发生指代 For Each sht In Sheets If sht.Name = Sheet1.Range("a" & i) Then k = 1 End If Next If k = 0 Then Sheets.Add after:=Sheets(Sheets.Count) Sheets(Sheets.Count).Name = Sheet1.Range("a" & i) End If Next End Sub
Sheet1.Activate
Sheet1.Range("a1").Select ‘选择前需要先激活
application.goto Sheets(1).Range("A1") ‘激活工作表和选择单元格在同一语句完成
Resize(2, 3).Select ‘resize只对于单元格 不对于可见区域
Sub shishi() Dim i As Integer Dim sht As Worksheet For i = 2 To Sheet1.Range("a65536").End(xlUp).Row ‘单元格循环 k = 0 For Each sht In Sheets If sht.Name = Sheet1.Range("d" & i) Then k = 1 End If Next If k = 0 Then Sheets.Add after:=Sheets(Sheets.Count) Sheets(Sheets.Count).Name = Sheet1.Range("d" & i) End If Next For Each sht In Sheets If sht.Name <> "数据" Then sht.Cells.ClearContents End If Sheet1.Activate ‘选择前需要先激活 Sheet1.Range("a1").Select Selection.AutoFilter ActiveSheet.Range("A1").AutoFilter Field:=4, Criteria1:=sht.Name Cells.Select If sht.Name <> "数据" Then Selection.Copy Sheets(sht.Name).Range("a1") End If Next Sheet1.Activate Sheet1.Range("a1").Select Selection.AutoFilter End Sub
Sub shishi() Dim i As Integer Dim sht As Worksheet Sheet1.Cells.ClearContents Sheet2.Range("a1").EntireRow.Copy Sheet1.Range("a1") For Each sht In Sheets For i = 2 To sht.Range("a65536").End(xlUp).Row If sht.Name <> "数据" Then sht.Range("a" & i).EntireRow.Copy Sheet1.Range("a" & Sheet1.Range("a65536").End(xlUp).Row + 1) End If Next Next End Sub
标签:需要 row 完成 可见 int sel 工作表 app end
原文地址:https://www.cnblogs.com/yigeduanpian/p/10041744.html