Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using Date as a Variable

I have cell contents and formulae in cells with fixed dates in them. I
need to create other versions of the workbook with different dates. So
I created a date variable. But when I run the procedure to replace the
fixed dates with another date, I get an error message:

Run-time error '1004':
Application-defined or object-defined error

Here is a simple example of what I have in the code.

Dim sCripDate As String
sCripDate = "2007,10,10"

With Worksheets("Cost")
.Range("D8").Value = "=DATE(sCripDate)"
End With

I must be doing something really silly. I tried setting the data type
to Date and that didn’t help. I am using XL 2007, but the code must
work down to XL 2002. Any help will be much appreciated.

Regards,
Les Allan
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Using Date as a Variable

hi
try it this way....
Sub testit()
Dim sCripDate As String
sCripDate = "2007,10,10"

With Worksheets("sheet1")
.Range("D8").Value = sCripDate '<--------
End With
End Sub

regards
FSt1

"Les Allan" wrote:

I have cell contents and formulae in cells with fixed dates in them. I
need to create other versions of the workbook with different dates. So
I created a date variable. But when I run the procedure to replace the
fixed dates with another date, I get an error message:

Run-time error '1004':
Application-defined or object-defined error

Here is a simple example of what I have in the code.

Dim sCripDate As String
sCripDate = "2007,10,10"

With Worksheets("Cost")
.Range("D8").Value = "=DATE(sCripDate)"
End With

I must be doing something really silly. I tried setting the data type
to Date and that didnt help. I am using XL 2007, but the code must
work down to XL 2002. Any help will be much appreciated.

Regards,
Les Allan
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using Date as a Variable

Thanks Mishell and Fst1. I spent ages trying to figure out what was
wrong.

Your solution worked Fst1; however, it doesn't put the date in the
cell in the right format. Mishell's solution worked like a treat.
Thanks again to both of you.

Does anyone know of any VBA developers in Melbourne, Australia?

Regards,
Les
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
Open file with variable date name based on current date Ciprian Excel Programming 1 January 7th 10 02:31 PM
Date Variable Ranjith Kurian[_2_] Excel Programming 6 March 26th 09 02:52 PM
variable for Date Ranjit kurian Excel Programming 10 January 23rd 09 04:54 PM
calc constant date from variable date & return with ability to rn. SusieQ'sQuest Excel Worksheet Functions 1 November 9th 04 08:51 PM
Compare Date in Cell VS a Variable Date to Hide Row JimI Excel Programming 3 October 10th 04 04:26 PM


All times are GMT +1. The time now is 04:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"