我正在设计一个宏,它将需要两张纸,一张原件和一张要从原件更新的纸张。它需要原件并复制工作表并按键排序。它还取消隐藏和取消过滤数据,以便所有键都按顺序排列。除了要更新的工作表之外,所有这些工作都没有变得过滤,我不明白为什么。任何帮助将不胜感激。
Sub crossUpdate()
Dim rng1 As Range, rng2 As Range, rng1Row As Range, rng2Row As Range, Key As Range, match As Integer
Workbooks("011 High Level Task List v2.xlsm").Activate
'Unhide and Unfilter columns and rows on original sheet
Sheet3.Cells.EntireColumn.Hidden = False
Sheet3.Cells.EntireRow.Hidden = False
Sheet3.Cells.AutoFilter
'Copy and paste original sheet to new temp sheet
Sheet3.Cells.Select
Selection.Copy
Sheets.Add.Name = "SourceData"
ActiveSheet.Paste
'Sort temp sheet by key
N = Cells(Rows.Count, "A").End(xlUp).Row
Set rng1 = Sheets("SourceData").Cells.Range("A2:A" & N)
Set rng1Row = rng1.EntireRow
rng1Row.Sort Key1:=Sheets("SourceData").Range("A1")
Workbooks("011 High Level Task List v2 ESI.xlsm").Activate
'Unhide and Unfilter columns and rows on update sheet
Sheet3.Cells.EntireColumn.Hidden = False
Sheet3.Cells.EntireRow.Hidden = False
Sheet3.AutoFilterMode = False
'Update sheet sorted by key
N = Cells(Rows.Count, "A").End(xlUp).Row
Set rng2 = Sheets("Sheet3").Cells.Range("A2:A" & N)
Set rng2Row = rng2.EntireRow
rng2Row.Sort Key1:=Sheets("Sheet3").Range("A1")
End Sub