Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA - Detecting a cell's format

Status
Not open for further replies.

CGSB

Programmer
May 23, 2006
35
CA
Is there a way to call a specific procedure when a cell formatted as date is clicked?
 
Hi, thanks for the tip. I'm tried using the format number property but it didn't work.

I made a mistake in my previous post. The cell is not formatted as a date, but rather its Category is set to Date in the Format Cells option. Now I need a way to open a form which contains a calendar whenever someone clicks on one of those cells.
 
Have a look at the BeforeRightClick event in help then post what you have tried and what you are trying to do in Forum707

Gavin
 
The format does not cause any validation, it only describes how the cell contents is displayed. When the cell is being formatted, its category and further details, if exist, are set. So you can either test 'NumberFormat' string to be valid date format or test the contents for valid data (positive response for proper data string too). The latter:
Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox IsDate(Target)
End Sub
More secure would be combination of both methods.



combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top