Question Locked

How do i know the current format of cell in excel?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Actually i need to display a calendar in which cell has the format as date. I got a code to display the calendar,
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If IsDate(ActiveCell.Value) Then

With Calendar1
.Visible = True
.Left = ActiveCell.Left + ActiveCell.Width
.Top = ActiveCell.Top
.Value = ActiveCell.Value
End With
Else
Calendar1.Visible = False
End If
End Sub

in this its responding when it has the date value but i need the cells in which cell has the date format..

2 replies

by belmhorst

Here is a handy little function that might do the trick for you. Right now I am just checking a static range and putting text in it whether or not it is formatted as a date. Give that a try and post back if you need to.

Function FindMyDates()
Dim cCell As Range

For Each cCell In Range("A1:C5")
If cCell.NumberFormat = "m/d/yyyy" Then
'Place your code here
cCell.Value = "Date"
Else
'Place other code here if you want
cCell.Value = "Date"
End If
Next
End Function

This discussion is closed to new replies.