ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why my code do not work : - ( (https://www.excelbanter.com/excel-programming/275727-re-why-my-code-do-not-work.html)

Bob Phillips[_5_]

Why my code do not work : - (
 
Soniya,

Try this

x = "=" & Format(Range("B1"),"dd/mm/yyyy")
y = "<=" & Format(Range("C1"),"dd/mm/yyyy")
or
x = "=" & CStr(Range("B1"))
y = "<=" & CStr(Range("C1"))

--

HTH

Bob Phillips

"Soniya" wrote in message
...
Hi all,

this is what i got while recording macro and worked fine..

Sheets("IncomeData").Select
Range("A2").Select
Range(Range("A2:F2"), Range("A2:F2").End
(xlDown)).Select
Selection.AutoFilter Field:=5,
Criteria1:="=01/07/2003", Operator:=xlAnd _
, Criteria2:="<=01/08/2003"

But when I changed it to:

x= "=" & range("B1")
y = "=" & Range("C1")

Range(Range("A2:F2"), Range("A2:F2").End
(xlDown)).Select
Selection.AutoFilter Field:=5, Criteria1:=x,
Operator:=xlAnd _
, Criteria2:=y

then no record shows in the filtered data.. while there
are several records meet the condition..

What would be the possible reason for this strange
behaviour...?

(I am using XL XP)

TIA
Soniya





All times are GMT +1. The time now is 06:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com