我有一个代码,该代码可以过滤数据并根据条件在新工作表上复制所需的行。我还想要复制单元格格式。我正在使用以下代码:
有人可以告诉我格式化部分哪里出错了吗?过滤器部分效果很好。
Private Sub CommandButton6_Click()
Dim wsFU As Worksheet
Dim wsTD As Worksheet
Set wsFU = Worksheets("Follow Up")
Set wsTD = Worksheets("Today")
Application.DisplayAlerts = False
wsTD.Delete
Application.DisplayAlerts = True
a = wsFU.Cells(Rows.Count, 1).End(xlUp).Row
wsFU.AutoFilterMode = False
ActiveWorkbook.Sheets.Add(After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)).Name = "Today"
Set wsTD = Worksheets("Today")
With wsFU.Range("A2:P" & a) 'adjust to end of date column
.AutoFilter Field:=15, Criteria1:=Format(Date, "mm/dd/yy")
.SpecialCells(xlCellTypeVisible).Copy Destination:=wsTD.Range("A1")
.PasteSpecial Paste:=xlPasteColumnWidths
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteFormulasAndNumberFormats
End With
wsFU.AutoFilterMode = False
End Sub