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/275734-re-why-my-code-do-not-work.html)

Tom Ogilvy

Why my code do not work : - (
 
Try

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

Note the 2 on the end of value.

--
Regards,
Tom Ogilvy


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




Tom Ogilvy

Why my code do not work : - (
 
Another possibility

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

also, I noticed that both your operators are "="
I assume one should be "<=" (probably y).

--
Regards,
Tom Ogilvy

Tom Ogilvy wrote in message
...
Try

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

Note the 2 on the end of value.

--
Regards,
Tom Ogilvy


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 04:00 AM.

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