Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does this code not work? rk0909 Excel Discussion (Misc queries) 12 September 4th 08 10:42 PM
Why this code is not work? Error code when select worksheet Excel Worksheet Functions 4 December 4th 07 12:51 AM
code is not to work on sheet1 Allan R Jeffery New Users to Excel 3 August 22nd 06 02:22 PM
Why my code do not work : - ( keepitcool Excel Programming 5 September 5th 03 06:28 PM
Why my code do not work : - ( Bob Phillips[_5_] Excel Programming 0 August 31st 03 01:27 PM


All times are GMT +1. The time now is 07:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"