![]() |
Cell references in macros
I have a macro with the following statement:
Selection.AutoFilter Field:=1, Criteria1:="=5/15/2006", Operator:=xlAnd _ , Criteria2:="<=5/28/2006" I want to replace the two dates with references to the values in cells B1 and B2 in the sheet "Macro Data". How do I do this? Dan |
Cell references in macros
Dan, you can play with this: (values in A1 & A2)
Selection.AutoFilter Field:=1, Criteria1:="=" & Cells(1, 1), Operator:=xlAnd _ , Criteria2:="<=" & Cells(2, 1) jr "Dan" wrote: I have a macro with the following statement: Selection.AutoFilter Field:=1, Criteria1:="=5/15/2006", Operator:=xlAnd _ , Criteria2:="<=5/28/2006" I want to replace the two dates with references to the values in cells B1 and B2 in the sheet "Macro Data". How do I do this? Dan |
Cell references in macros
JR,
Thank you for your reply. I have a date in both B1 and B2 (sheet "Macro Data"). In my macro, I have the following code: Dim EndDate As Date Dim StartDate As Date StartDate = Sheets("Macro Data").Cells("B1") EndDate = Sheets("Macro Data").Cells("B2") Then I am going to use StartDate and EndDate in the AutoFilter statement that I gave in my previous message. However, the above statements are giving me error 13 (type mismatch). Can you help me with what's wrong with what I'm doing? Thanks! Dan "JR in NC" wrote: Dan, you can play with this: (values in A1 & A2) Selection.AutoFilter Field:=1, Criteria1:="=" & Cells(1, 1), Operator:=xlAnd _ , Criteria2:="<=" & Cells(2, 1) jr "Dan" wrote: I have a macro with the following statement: Selection.AutoFilter Field:=1, Criteria1:="=5/15/2006", Operator:=xlAnd _ , Criteria2:="<=5/28/2006" I want to replace the two dates with references to the values in cells B1 and B2 in the sheet "Macro Data". How do I do this? Dan |
All times are GMT +1. The time now is 10:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com