Tags: below, cell, cells, code, confirming, date, despite, excel, format, isntworking, microsoft, msdn, properly, software, vba

VBA Date Format Cell Check

On Microsoft » Microsoft Excel

2,510 words with 2 Comments; publish: Fri, 30 May 2008 20:24:00 GMT; (30695.70, « »)

Hi,

I'm trying to check cells for Date format or not, but the code below isn't

working properly. Despite confirming the Date format in the cells being

checked, my code isn't running the command (ActiveCell.Offset(1, 0).Activate

Instead, it's branching to the Else command, which I do not want. This seems

simple, can someone help?

If ActiveCell.NumberFormat = "Date" Then

ActiveCell.Offset(1, 0).Activate

Else

ActiveCell.Select

Selection.Cut

ActiveCell.Offset(-1, 1).Activate

ActiveSheet.Paste

ActiveCell.Offset(1, -1).Activate

End If

Thanks!

Kim

All Comments

Leave a comment...

  • 2 Comments
    • Maybe

      If IsDate(ActiveCell.Value) Then

      Stop

      ActiveCell.Offset(1, 0).Activate

      Else

      ActiveCell.Select

      Selection.Cut

      ActiveCell.Offset(-1, 1).Activate

      ActiveSheet.Paste

      ActiveCell.Offset(1, -1).Activate

      End If

      Mike

      "Kim" wrote:

      > Hi,

      > I'm trying to check cells for Date format or not, but the code below isn't

      > working properly. Despite confirming the Date format in the cells being

      > checked, my code isn't running the command (ActiveCell.Offset(1, 0).Activate

      > Instead, it's branching to the Else command, which I do not want. This seems

      > simple, can someone help?

      > If ActiveCell.NumberFormat = "Date" Then

      > ActiveCell.Offset(1, 0).Activate

      > Else

      > ActiveCell.Select

      > Selection.Cut

      > ActiveCell.Offset(-1, 1).Activate

      > ActiveSheet.Paste

      > ActiveCell.Offset(1, -1).Activate

      > End If

      >

      > Thanks!

      > Kim

      #1; Fri, 30 May 2008 20:26:00 GMT
    • Or have i misunderstood, do you mean

      If ActiveCell.NumberFormat = "mm/dd/yyyy" Then

      Mike

      "Kim" wrote:

      > Hi,

      > I'm trying to check cells for Date format or not, but the code below isn't

      > working properly. Despite confirming the Date format in the cells being

      > checked, my code isn't running the command (ActiveCell.Offset(1, 0).Activate

      > Instead, it's branching to the Else command, which I do not want. This seems

      > simple, can someone help?

      > If ActiveCell.NumberFormat = "Date" Then

      > ActiveCell.Offset(1, 0).Activate

      > Else

      > ActiveCell.Select

      > Selection.Cut

      > ActiveCell.Offset(-1, 1).Activate

      > ActiveSheet.Paste

      > ActiveCell.Offset(1, -1).Activate

      > End If

      >

      > Thanks!

      > Kim

      #2; Fri, 30 May 2008 20:27:00 GMT