View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Nigel RS[_2_] Nigel RS[_2_] is offline
external usenet poster
 
Posts: 80
Default 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