Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Why my code do not work : - (

soniya..

Either your columns OR B1/C1 contain data that looks like dates but in
fact are strings(text).

OR

your data or b1/c1 contains timeportions



maybe changing to
x = "=" & range("B1").text
y = "=" & Range("C1").text

or
x = "=" & int(range("B1"))
y = "=" & int(range("C1"))



will help, but I suggest to make sure
u use the same data types in search range
and criteria cells



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Soniya" wrote:

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: 48
Default Why my code do not work : - (


Still the Same : - (

????!!!!

what works manual do not work by code?

even the recorded code do not work in the second
instance??!!!!

Soniya

-----Original Message-----
soniya..

Either your columns OR B1/C1 contain data that looks

like dates but in
fact are strings(text).

OR

your data or b1/c1 contains timeportions



maybe changing to
x = "=" & range("B1").text
y = "=" & Range("C1").text

or
x = "=" & int(range("B1"))
y = "=" & int(range("C1"))



will help, but I suggest to make sure
u use the same data types in search range
and criteria cells



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Soniya" wrote:

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



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Why my code do not work : - (

Soniya,

Did you try my suggestion?

--

HTH

Bob Phillips

"Soniya" wrote in message
...

Still the Same : - (

????!!!!

what works manual do not work by code?

even the recorded code do not work in the second
instance??!!!!

Soniya

-----Original Message-----
soniya..

Either your columns OR B1/C1 contain data that looks

like dates but in
fact are strings(text).

OR

your data or b1/c1 contains timeportions



maybe changing to
x = "=" & range("B1").text
y = "=" & Range("C1").text

or
x = "=" & int(range("B1"))
y = "=" & int(range("C1"))



will help, but I suggest to make sure
u use the same data types in search range
and criteria cells



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Soniya" wrote:

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



.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Why my code do not work : - (

Thanks Bob, Tom and KeepITCool


Now it works fine..

I used Toms Value2 option..

why Value2 ?
its new for me..


Regards,

Soniya


-----Original Message-----
soniya,
send me your book and i'll have a look.
address below

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Soniya" wrote:


Still the Same : - (

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Why my code do not work : - (

It appeared to me the problem was that Excel VBA was treating your dates as
US format. when you use the value property with a cell containing a date it
gets translated as a date string and gets misinterpreted (if the day and
month values are ambiguous). Value2 returns the date serial number.

To demo from the immediate window:

? activeCell.Value
1/21/03
? activeCell.Value2
37642

--
Regards,
Tom Ogilvy


Soniya wrote in message
...
Thanks Bob, Tom and KeepITCool


Now it works fine..

I used Toms Value2 option..

why Value2 ?
its new for me..


Regards,

Soniya


-----Original Message-----
soniya,
send me your book and i'll have a look.
address below

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Soniya" wrote:


Still the Same : - (

.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Why my code do not work : - (

XL2000: Description of the Value2 Property for the Range Object
http://support.microsoft.com/default...b;en-us;213719

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =

"Soniya" wrote in message
...
Thanks Bob, Tom and KeepITCool

Now it works fine..

I used Toms Value2 option..

why Value2 ?
its new for me..

Regards,
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
Maco code doesn't work. Why? Joe M. Excel Discussion (Misc queries) 2 January 13th 10 07:13 PM
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 : - ( Bob Phillips[_5_] Excel Programming 0 August 31st 03 01:27 PM


All times are GMT +1. The time now is 03:30 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"