Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variant/Double?!?
Hi,
I have an Excel sheet that updates productionnumbers and compares them against yesterdays predictions. In this sheet I got a problem, in the code below. If Sheets(Blad).Cells(3, 1).Value < Sheets("MÃ¥l_V").Cells(3, 2).Value Then The value that excel presents is: Sheets(Blad).Cells(3, 1).Value : 20060531 : Variant/Double Sheets("MÃ¥l_V").Cells(3, 2).Value : "20060531" : Variant/String I have tried to change so that both to have the form "Text". And if I put a ' in front "Sheets(Blad).Cells(3, 1).Value" then they become equal. But the next day I will have the same problem. How do I fix this? Peter Arvidsson |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variant/Double?!?
Try.....
If Cstr(Sheets(Blad).Cells(3, 1).Value) < Sheets("MÃ¥l_V").Cells(3, 2).Value Then "PeterArvidsson" wrote: Hi, I have an Excel sheet that updates productionnumbers and compares them against yesterdays predictions. In this sheet I got a problem, in the code below. If Sheets(Blad).Cells(3, 1).Value < Sheets("MÃ¥l_V").Cells(3, 2).Value Then The value that excel presents is: Sheets(Blad).Cells(3, 1).Value : 20060531 : Variant/Double Sheets("MÃ¥l_V").Cells(3, 2).Value : "20060531" : Variant/String I have tried to change so that both to have the form "Text". And if I put a ' in front "Sheets(Blad).Cells(3, 1).Value" then they become equal. But the next day I will have the same problem. How do I fix this? Peter Arvidsson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variant/Double?!?
Maybe try this
If CStr(Sheets(Blad).Cells(3, 1).Value) < _ CStr(Sheets("Mål_V").Cells(3, 2).Value) Then -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "PeterArvidsson" wrote in message ... Hi, I have an Excel sheet that updates productionnumbers and compares them against yesterdays predictions. In this sheet I got a problem, in the code below. If Sheets(Blad).Cells(3, 1).Value < Sheets("Mål_V").Cells(3, 2).Value Then The value that excel presents is: Sheets(Blad).Cells(3, 1).Value : 20060531 : Variant/Double Sheets("Mål_V").Cells(3, 2).Value : "20060531" : Variant/String I have tried to change so that both to have the form "Text". And if I put a ' in front "Sheets(Blad).Cells(3, 1).Value" then they become equal. But the next day I will have the same problem. How do I fix this? Peter Arvidsson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variant/Double?!?
Thank you, works like a charm.
What did Cstr do to the code? /Peter "Nigel RS" skrev: Try..... If Cstr(Sheets(Blad).Cells(3, 1).Value) < Sheets("MÃ¥l_V").Cells(3, 2).Value Then "PeterArvidsson" wrote: Hi, I have an Excel sheet that updates productionnumbers and compares them against yesterdays predictions. In this sheet I got a problem, in the code below. If Sheets(Blad).Cells(3, 1).Value < Sheets("MÃ¥l_V").Cells(3, 2).Value Then The value that excel presents is: Sheets(Blad).Cells(3, 1).Value : 20060531 : Variant/Double Sheets("MÃ¥l_V").Cells(3, 2).Value : "20060531" : Variant/String I have tried to change so that both to have the form "Text". And if I put a ' in front "Sheets(Blad).Cells(3, 1).Value" then they become equal. But the next day I will have the same problem. How do I fix this? Peter Arvidsson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variant/Double?!?
Casts the variable to string, forces string comparison. See my version, a
little more robust. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "PeterArvidsson" wrote in message ... Thank you, works like a charm. What did Cstr do to the code? /Peter "Nigel RS" skrev: Try..... If Cstr(Sheets(Blad).Cells(3, 1).Value) < Sheets("Mål_V").Cells(3, 2).Value Then "PeterArvidsson" wrote: Hi, I have an Excel sheet that updates productionnumbers and compares them against yesterdays predictions. In this sheet I got a problem, in the code below. If Sheets(Blad).Cells(3, 1).Value < Sheets("Mål_V").Cells(3, 2).Value Then The value that excel presents is: Sheets(Blad).Cells(3, 1).Value : 20060531 : Variant/Double Sheets("Mål_V").Cells(3, 2).Value : "20060531" : Variant/String I have tried to change so that both to have the form "Text". And if I put a ' in front "Sheets(Blad).Cells(3, 1).Value" then they become equal. But the next day I will have the same problem. How do I fix this? Peter Arvidsson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variant/Double?!?
If you want something even more robust then trim each string in case of those
'hidden' spaces that can creep in! If Trim(CStr(Sheets(Blad).Cells(3, 1).Value)) < _ Trim(CStr(Sheets("MÃ¥l_V").Cells(3, 2).Value)) Then "Bob Phillips" wrote: Casts the variable to string, forces string comparison. See my version, a little more robust. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "PeterArvidsson" wrote in message ... Thank you, works like a charm. What did Cstr do to the code? /Peter "Nigel RS" skrev: Try..... If Cstr(Sheets(Blad).Cells(3, 1).Value) < Sheets("MÃ¥l_V").Cells(3, 2).Value Then "PeterArvidsson" wrote: Hi, I have an Excel sheet that updates productionnumbers and compares them against yesterdays predictions. In this sheet I got a problem, in the code below. If Sheets(Blad).Cells(3, 1).Value < Sheets("MÃ¥l_V").Cells(3, 2).Value Then The value that excel presents is: Sheets(Blad).Cells(3, 1).Value : 20060531 : Variant/Double Sheets("MÃ¥l_V").Cells(3, 2).Value : "20060531" : Variant/String I have tried to change so that both to have the form "Text". And if I put a ' in front "Sheets(Blad).Cells(3, 1).Value" then they become equal. But the next day I will have the same problem. How do I fix this? Peter Arvidsson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variant/Double?!?
You should then also replace any Chat(160) with "", much data web copied has
them. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Nigel RS" wrote in message ... If you want something even more robust then trim each string in case of those 'hidden' spaces that can creep in! If Trim(CStr(Sheets(Blad).Cells(3, 1).Value)) < _ Trim(CStr(Sheets("Mål_V").Cells(3, 2).Value)) Then "Bob Phillips" wrote: Casts the variable to string, forces string comparison. See my version, a little more robust. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "PeterArvidsson" wrote in message ... Thank you, works like a charm. What did Cstr do to the code? /Peter "Nigel RS" skrev: Try..... If Cstr(Sheets(Blad).Cells(3, 1).Value) < Sheets("Mål_V").Cells(3, 2).Value Then "PeterArvidsson" wrote: Hi, I have an Excel sheet that updates productionnumbers and compares them against yesterdays predictions. In this sheet I got a problem, in the code below. If Sheets(Blad).Cells(3, 1).Value < Sheets("Mål_V").Cells(3, 2).Value Then The value that excel presents is: Sheets(Blad).Cells(3, 1).Value : 20060531 : Variant/Double Sheets("Mål_V").Cells(3, 2).Value : "20060531" : Variant/String I have tried to change so that both to have the form "Text". And if I put a ' in front "Sheets(Blad).Cells(3, 1).Value" then they become equal. But the next day I will have the same problem. How do I fix this? Peter Arvidsson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
double axis, double problem (i hope only to me) | Charts and Charting in Excel | |||
Variant | Excel Programming | |||
Variant as matrix | Excel Programming | |||
Declaring As Variant, Changing to Double? | Excel Programming | |||
Testing if Variant is Range or Double? | Excel Programming |