[FONT="]Hi, So in my macro I have[/FONT]
[FONT="]
[/FONT]
[FONT="]Dim TradeDate As Range[/FONT]
[FONT="]Set TradeDate = Active sheet.Range("AA1")[/FONT]
[FONT="]Sheets("Sheet1").Activate[/FONT]
[FONT="]Range("A1").AutoFilter Field:=4, Criteria1:=TradeDate[/FONT]
[FONT="]
[/FONT]
[FONT="]The filtered results are good in my pivot table[/FONT]
[FONT="]
[/FONT]
[FONT="]But when I need this in another macro with the same date:[/FONT]
[FONT="]Dim TradeDate As Range[/FONT]
[FONT="]Set TradeDate = Active sheet.Range("AA1")[/FONT]
[FONT="]Sheets("Sheet1").Activate[/FONT]
[FONT="]Range("A1").AutoFilter Field:=4, Criteria1:="<>TradeDate"[/FONT]
[FONT="]
[/FONT]
[FONT="]Basically, just the criteria1 that changes and it it not working, because it is showing the date I want to filter out. Why is it doing this???[/FONT]
[FONT="]
[/FONT]
[FONT="]Thank you
Just in case, TradeDate is given like this:
[/FONT]
Range("AA1").Select
ActiveCell.FormulaR1C1 = "=IF(WEEKDAY(TODAY())=2,TODAY()-3,TODAY()-1)"
Selection.NumberFormat = "dd.mm.yyyy"
Range("AB1").Select
ActiveCell.FormulaR1C1 = "=TEXT(RC[-1],""dd.mm.yyyy"")"
Range("AB1").Select
Selection.Copy
Range("AC1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set myCell = Range("AC1")
With myCell
.Application.SendKeys "{F2}"
.Application.SendKeys "{ENTER}"
End With
Range("AA1:AB1").Select
Selection.Delete Shift:=xlToLeft
[FONT="]
[/FONT]
[FONT="]
[/FONT]
[FONT="]Dim TradeDate As Range[/FONT]
[FONT="]Set TradeDate = Active sheet.Range("AA1")[/FONT]
[FONT="]Sheets("Sheet1").Activate[/FONT]
[FONT="]Range("A1").AutoFilter Field:=4, Criteria1:=TradeDate[/FONT]
[FONT="]
[/FONT]
[FONT="]The filtered results are good in my pivot table[/FONT]
[FONT="]
[/FONT]
[FONT="]But when I need this in another macro with the same date:[/FONT]
[FONT="]Dim TradeDate As Range[/FONT]
[FONT="]Set TradeDate = Active sheet.Range("AA1")[/FONT]
[FONT="]Sheets("Sheet1").Activate[/FONT]
[FONT="]Range("A1").AutoFilter Field:=4, Criteria1:="<>TradeDate"[/FONT]
[FONT="]
[/FONT]
[FONT="]Basically, just the criteria1 that changes and it it not working, because it is showing the date I want to filter out. Why is it doing this???[/FONT]
[FONT="]
[/FONT]
[FONT="]Thank you
Just in case, TradeDate is given like this:
[/FONT]
Range("AA1").Select
ActiveCell.FormulaR1C1 = "=IF(WEEKDAY(TODAY())=2,TODAY()-3,TODAY()-1)"
Selection.NumberFormat = "dd.mm.yyyy"
Range("AB1").Select
ActiveCell.FormulaR1C1 = "=TEXT(RC[-1],""dd.mm.yyyy"")"
Range("AB1").Select
Selection.Copy
Range("AC1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set myCell = Range("AC1")
With myCell
.Application.SendKeys "{F2}"
.Application.SendKeys "{ENTER}"
End With
Range("AA1:AB1").Select
Selection.Delete Shift:=xlToLeft
[FONT="]
[/FONT]