ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I check if a cell is formatted as a date in Excel VB? (https://www.excelbanter.com/excel-worksheet-functions/242186-how-do-i-check-if-cell-formatted-date-excel-vbulletin.html)

Alex@LM

How do I check if a cell is formatted as a date in Excel VB?
 
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

Gertjan Huiskes[_2_]

How do I check if a cell is formatted as a date in Excel VB?
 
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...
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




Alex@LM[_2_]

How do I check if a cell is formatted as a date in Excel VB?
 
Thank you, Gertjan. This is just what I needed!

"Gertjan Huiskes" wrote:

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...
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






All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com