Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Maco code doesn't work. Why? | Excel Discussion (Misc queries) | |||
Why does this code not work? | Excel Discussion (Misc queries) | |||
Why this code is not work? | Excel Worksheet Functions | |||
code is not to work on sheet1 | New Users to Excel | |||
Why my code do not work : - ( | Excel Programming |