我有一个应用条件格式和过滤器的宏。宏应该过滤文件并将其保存,然后应删除过滤器并使用不同的列再次过滤并将这些结果保存到另一个文件中。宏正在运行,但是文件似乎没有保存?
代码
Sub Customer_Connections()
'
' Macro1 Macro
'
Application.ScreenUpdating = False
' Email Must Be In Column F
'Duplicate Email
Columns("F:F").Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$Z$999999").AutoFilter Field:=6, Criteria1:=RGB(255, _
199, 206), Operator:=xlFilterCellColor
ActiveWorkbook.SaveCopyAs ("Duplicate_Emails-" & Format(Now(), "ddmmyyyy") & ".xlsm")
'More Than One @
With Sheets("Customer Connections")
.Columns("G:G").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
.Columns("G:G").NumberFormat = "General"
Cells.Select
Selection.AutoFilter
With .Range("G2:G" & .Range("A" & .Rows.Count).End(xlUp).Row)
.Formula = "=LEN(RC[-1])-LEN(SUBSTITUTE(RC[-1],""@"",""""))"
.Copy
.PasteSpecial xlPasteValues
End With
Range("G1").Select
ActiveCell.FormulaR1C1 = "Count Of @"
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$L$999999").AutoFilter Field:=7, Criteria1:="2"
End With
ActiveWorkbook.SaveCopyAs ("Two_@_In_Emails-" & Format(Now(), "mmddyyyy") & ".xlsm")
End Sub
答案 0 :(得分:1)
尝试一下:
ActiveWorkbook.SaveCopyAs ActiveWorkbook.Path & _
"\Two_@_In_Emails-" & Format(Now(), "mmddyyyy") & ".xlsm"