Year in VB

T

Taurus

I try to change the year in general format from the spreadsheet to the
"yyyy/mm/dd"

I am not allow to change the format in the spreadsheet.

For example, year in the spreadsheet in 1999(general format)

I would like to convert to "yyyy/mm/dd" in VB

How do I do that? Please advise

Thank you
 
J

JE McGimpsey

Taurus said:
I try to change the year in general format from the spreadsheet to the
"yyyy/mm/dd"

I am not allow to change the format in the spreadsheet.

For example, year in the spreadsheet in 1999(general format)

I would like to convert to "yyyy/mm/dd" in VB

How do I do that? Please advise

Not sure exactly what you're asking for - XL takes its default format
from the System Preferences (International Pane).

You could generate a style (Format/Style), say MyDate with the number
format you want, then apply the style to all relevant cells.

You could use VBA, but I'm not sure from your description where you want
to apply it. It's easy to apply it to cells:

Range("A1:A100").NumberFormat = "yyyy/mm/dd"

And you can set up styles in VB, too:

Range("A1:A100").Style = "MyDate"

If you really can't change the format in the spreadsheet, are you
looking to make the date a text entry?

With Range("A1")
.NumberFormat = "@"
.Value = Format(.Value - 1462 * ActiveWorkbook.Date1904, _
"yyyy/mm/dd")
End With
 

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

Top