Cell Values Entered by Macro

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Hello

This is driving me insane! I have a macro that enters a
date value into a cell using the following line:

Cells(x,y).value = Format(Date, "dd/mm/yyyy")

That works great, however the value is entered into the
cell as a string, like "25/04/2004", and not a date. Is
there anything i'm doing wrong? I know that It's a string
because the value is left justified in the cell, and Excel
throws a #VALUE! at me if I try to perform any arithmetic
on the value.

I've also tried

Cells(x,y).value = Format(Now, "dd/mm/yyyy")

Which give the same result!

Any Ideas gratefully recieved!

TIA, Kevin
 
Hi Kevin

I think you'll have to format the destination cells to be
dates in advance or in code somehow because the Format()
funtion will always return a string. Hope this helps!

Tanner
(e-mail address removed)
 
Hi
try
with Cells(x,y)
.value = date
.numberformat = "DD/MM/YYYY"
end with
 
In addition to what Kalle said, and this might seem obvious to you - but make sure the cell is not set to a text format

-Brad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top