Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Date Issue in excel vba

Hello all,

i'm having an issue with a date variable in excel vba that i can't
figure out. I hope someone can tell me what's wrong and how come it's
happening.

On one of my spread sheet i have 2 dates. A start date and a end
date. I did some code by creating a module in vb.

DIM Dt1 as date
DIM Dt2 as date

The problem is that when i look at what the value of dt1 and dt2 in
worksheet1, it only shows 12:00am. is there some way that i need to
specified to show the exact date on my sheet?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Date Issue in excel vba

On Sep 10, 2:01 pm, JW wrote:
You are just declaring the variable. You need to assign a value to
the variable.
Sub foo2()
Dim Dt1 As Date
Dim Dt2 As Date
Dt1 = Date
Dt2 = Date + 5
MsgBox Dt1 & Chr(10) & Dt2
End Sub



wrote:
Hello all,


i'm having an issue with a date variable in excel vba that i can't
figure out. I hope someone can tell me what's wrong and how come it's
happening.


On one of my spread sheet i have 2 dates. A start date and a end
date. I did some code by creating a module in vb.


DIM Dt1 as date
DIM Dt2 as date


The problem is that when i look at what the value of dt1 and dt2 in
worksheet1, it only shows 12:00am. is there some way that i need to
specified to show the exact date on my sheet?- Hide quoted text -


- Show quoted text -


What if i have 2 dates already in another sheet and wanted to get the
value from the sheet?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Date Issue in excel vba

On Sep 10, 2:14 pm, JW wrote:
Sub foo2()
Dim Dt1 As String
Dim Dt2 As String
Dt1 = Sheets("Sheet1").Range("C15").Text
Dt2 = Sheets("Sheet1").Range("C16").Text
MsgBox Dt1 & Chr(10) & Dt2
End Sub



wrote:
On Sep 10, 2:01 pm, JW wrote:
You are just declaring the variable. You need to assign a value to
the variable.
Sub foo2()
Dim Dt1 As Date
Dim Dt2 As Date
Dt1 = Date
Dt2 = Date + 5
MsgBox Dt1 & Chr(10) & Dt2
End Sub


wrote:
Hello all,


i'm having an issue with a date variable in excel vba that i can't
figure out. I hope someone can tell me what's wrong and how come it's
happening.


On one of my spread sheet i have 2 dates. A start date and a end
date. I did some code by creating a module in vb.


DIM Dt1 as date
DIM Dt2 as date


The problem is that when i look at what the value of dt1 and dt2 in
worksheet1, it only shows 12:00am. is there some way that i need to
specified to show the exact date on my sheet?- Hide quoted text -


- Show quoted text -


What if i have 2 dates already in another sheet and wanted to get the
value from the sheet?- Hide quoted text -


- Show quoted text -


Thanks JW.

Can you explain the following 2 lines? I'm looking at a process that
was written by someone else and didn't know what these 2 line was
doing.

res = Application.Match(CLng(dt1), r, 0)
res1 = Application.Match(CLng(dt2), r, 0)

res variable returns a 2042 error.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Date Issue in excel vba

Without seeing the whole code and what the variables are assigned,
it's tough to determiine what the variables should return.
The res variables are using a Match function to return the position
within the r array where the dt1 variable first occurs. I know that
sounds a little complex, but that's what it is doing. If you are
receiving an error, it's probably because the Match function can not
find a match to dt1 within the r array.
Application.Match(CLng(dt1), r, 0)
wrote:
On Sep 10, 2:14 pm, JW wrote:
Sub foo2()
Dim Dt1 As String
Dim Dt2 As String
Dt1 = Sheets("Sheet1").Range("C15").Text
Dt2 = Sheets("Sheet1").Range("C16").Text
MsgBox Dt1 & Chr(10) & Dt2
End Sub



wrote:
On Sep 10, 2:01 pm, JW wrote:
You are just declaring the variable. You need to assign a value to
the variable.
Sub foo2()
Dim Dt1 As Date
Dim Dt2 As Date
Dt1 = Date
Dt2 = Date + 5
MsgBox Dt1 & Chr(10) & Dt2
End Sub


wrote:
Hello all,


i'm having an issue with a date variable in excel vba that i can't
figure out. I hope someone can tell me what's wrong and how come it's
happening.


On one of my spread sheet i have 2 dates. A start date and a end
date. I did some code by creating a module in vb.


DIM Dt1 as date
DIM Dt2 as date


The problem is that when i look at what the value of dt1 and dt2 in
worksheet1, it only shows 12:00am. is there some way that i need to
specified to show the exact date on my sheet?- Hide quoted text -


- Show quoted text -


What if i have 2 dates already in another sheet and wanted to get the
value from the sheet?- Hide quoted text -


- Show quoted text -


Thanks JW.

Can you explain the following 2 lines? I'm looking at a process that
was written by someone else and didn't know what these 2 line was
doing.

res = Application.Match(CLng(dt1), r, 0)
res1 = Application.Match(CLng(dt2), r, 0)

res variable returns a 2042 error.


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
Date issue Patrick C. Simonds Excel Worksheet Functions 6 January 7th 09 08:00 PM
Date Issue with Microsoft Excel Adit Shah Excel Discussion (Misc queries) 1 January 14th 08 02:00 PM
Excel date format issue rs-excel Excel Discussion (Misc queries) 1 October 17th 06 11:37 PM
Excel 2003: date display issue Andrew Excel Discussion (Misc queries) 17 July 13th 06 05:36 PM
DATE ISSUE! Joan Excel Worksheet Functions 2 June 15th 06 03:39 PM


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