Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Strange Values

Hi all,

I am wanting someone to help me with my problem. I have a problem with dates.

Dim toDate, fromDate as string

toDate = sheets("data").cells(2,5).value
fromDate = Sheets("data").cells(2,27).value

The problem is that the value for toDate = 1/7/2001 and the value for
fromDate = "1/7/2002".

How do I take the "" out, I have tried everything? The only difference in
the above is the cell reference.

Can anyone help or suggestions would be great?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Strange Values

You have declared toDate as variant, fromDate as string.
You tried everything, so it may be silly to suggest

Dim toDate as Date, fromDate as Date

but that's what I'd use.

Best wishes Harald

"Ashman" skrev i melding
...
Hi all,

I am wanting someone to help me with my problem. I have a problem with

dates.

Dim toDate, fromDate as string

toDate = sheets("data").cells(2,5).value
fromDate = Sheets("data").cells(2,27).value

The problem is that the value for toDate = 1/7/2001 and the value for
fromDate = "1/7/2002".

How do I take the "" out, I have tried everything? The only difference in
the above is the cell reference.

Can anyone help or suggestions would be great?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Strange Values

Your line

Dim toDate, fromDate As String

declares toDate to be a Variant, and fromDate to be a String. Unlike C,
the type declaration doesn't apply to the entire line.

If you want them both to be dates, try

Dim toDate As Date, fromDate As Date





In article ,
Ashman wrote:

Hi all,

I am wanting someone to help me with my problem. I have a problem with dates.

Dim toDate, fromDate as string

toDate = sheets("data").cells(2,5).value
fromDate = Sheets("data").cells(2,27).value

The problem is that the value for toDate = 1/7/2001 and the value for
fromDate = "1/7/2002".

How do I take the "" out, I have tried everything? The only difference in
the above is the cell reference.

Can anyone help or suggestions would be great?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Strange Values

fromDate is dimensioned as String and hence will have the "" whereas todate
is variant by default.

Dim toDate, fromDate

Dim toDate as String, fromDate as String

Dim toDate as Date, fromDate as Date

HTH

"Ashman" wrote:

Hi all,

I am wanting someone to help me with my problem. I have a problem with dates.

Dim toDate, fromDate as string

toDate = sheets("data").cells(2,5).value
fromDate = Sheets("data").cells(2,27).value

The problem is that the value for toDate = 1/7/2001 and the value for
fromDate = "1/7/2002".

How do I take the "" out, I have tried everything? The only difference in
the above is the cell reference.

Can anyone help or suggestions would be great?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Strange Values

Mate, many thanks, works perfectly. You are a life saver.

Jas

"Duke Carey" wrote:

don't DIM fromDate as a String. The way your DIM statement reads, toDate is
a variant. Cast them both as Date

"Ashman" wrote:

Hi all,

I am wanting someone to help me with my problem. I have a problem with dates.

Dim toDate, fromDate as string

toDate = sheets("data").cells(2,5).value
fromDate = Sheets("data").cells(2,27).value

The problem is that the value for toDate = 1/7/2001 and the value for
fromDate = "1/7/2002".

How do I take the "" out, I have tried everything? The only difference in
the above is the cell reference.

Can anyone help or suggestions would be great?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,081
Default Strange Values

don't DIM fromDate as a String. The way your DIM statement reads, toDate is
a variant. Cast them both as Date

"Ashman" wrote:

Hi all,

I am wanting someone to help me with my problem. I have a problem with dates.

Dim toDate, fromDate as string

toDate = sheets("data").cells(2,5).value
fromDate = Sheets("data").cells(2,27).value

The problem is that the value for toDate = 1/7/2001 and the value for
fromDate = "1/7/2002".

How do I take the "" out, I have tried everything? The only difference in
the above is the cell reference.

Can anyone help or suggestions would be great?

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
Strange FreedomHillFarm Excel Worksheet Functions 1 January 13th 11 01:12 PM
Strange?! Jo[_2_] Excel Discussion (Misc queries) 6 August 8th 07 07:01 PM
Strange behavior with text box values . . . help! WillRn Excel Programming 1 January 24th 05 10:14 PM
2 strange ones.. RC[_5_] Excel Programming 0 November 15th 04 03:45 PM
Strange behavior Chart.SeriesCollection(n).Values property Emile van Mierlo Excel Programming 3 June 19th 04 06:07 PM


All times are GMT +1. The time now is 10:32 PM.

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"