How do I check if a cell is formatted as a date in Excel VB?

A

Alex@LM

I'm using MS Office Excel 2007; trying to write VB function to update a cell
content with a date; would like to first determine if that cell already has
been formatted as a date; otherwise do not update
 
G

Gertjan Huiskes

Alex,

This statement checks if the format contains a day in the format for cell
A1:

If InStr(Range("A1").NumberFormat, "d") > 0 Then
' Cell is formatted as a date
End If

Greetz, Gertjan

Alex@LM wrote...
 
A

Alex@LM

Thank you, Gertjan. This is just what I needed!

Gertjan Huiskes said:
Alex,

This statement checks if the format contains a day in the format for cell
A1:

If InStr(Range("A1").NumberFormat, "d") > 0 Then
' Cell is formatted as a date
End If

Greetz, Gertjan

Alex@LM wrote...
 

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