Typing in dates

ALLAROUNDOFFICE

Board Regular
Joined
Apr 26, 2014
Messages
61
How can I hard code a column of cells to convert the user entered data of "042614" or "42614" into a specific date format such as 04/26/2014?
 
I don't get it... it works for me.:confused:

We need help here from the rest of you reading this thread... install the code in Message #20 using the install instruction in Message #4, then type values 040114, 121514 and so on (where the numbers are mmddyy values with date delimiters in them) and tell us if those values are converted to real dates or not.
Could it be possible that my spreadsheet isn't even recognizing the event code procedure??? Is there a test we can run to confirm?
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Add the lines in red

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Cell As Range
  On Error GoTo NothingInColumn
  If Not Intersect(Target, Columns("A")) Is Nothing Then
  [COLOR="#FF0000"]MsgBox "done1!!!!"[/COLOR]
    For Each Cell In Intersect(Target, Intersect(Columns("A"), ActiveSheet.UsedRange))
      If Not IsDate(Cell.Value) And Not Cell.Value Like "*[!0-9]*" Then
         Cell.NumberFormat = "General"
        Cell.Value = Format(Cell.Value, "0/00/00")
        [COLOR="#FF0000"]MsgBox "done2!!!!"[/COLOR]
      End If
    Next
  End If
NothingInColumn:
End Sub
 
Last edited:
Upvote 0
Add the lines in red

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Cell As Range
  On Error GoTo NothingInColumn
  If Not Intersect(Target, Columns("A")) Is Nothing Then
  [COLOR=#ff0000]MsgBox "done1!!!!"[/COLOR]
    For Each Cell In Intersect(Target, Intersect(Columns("A"), ActiveSheet.UsedRange))
      If Not IsDate(Cell.Value) And Not Cell.Value Like "*[!0-9]*" Then
         Cell.NumberFormat = "General"
        Cell.Value = Format(Cell.Value, "0/00/00")
        [COLOR=#ff0000]MsgBox "done2!!!!"[/COLOR]
      End If
    Next
  End If
NothingInColumn:
End Sub
I did that and nothing changed...What does that tell us?
 
Upvote 0
I did that and nothing changed...What does that tell us?

The question was
Could it be possible that my spreadsheet isn't even recognizing the event code procedure??? Is there a test we can run to confirm?
Did you get the message boxes when you typed a number in Column A? If you get the message boxes then it definitely is recognizing it.
 
Upvote 0
Then I would say the sheet isn't recognizing the code, only problem is I can't think why at present.

If I do think of any reason why it would stop after it was firing earlier then I'll post back.
 
Upvote 0
then i would say the sheet isn't recognizing the code, only problem is i can't think why at present.

If i do think of any reason why it would stop after it was firing earlier then i'll post back.
that's just it...i don't think it was ever firing...rick sent me instructions on how to create one since i had never done it before, so perhaps we both missed a step???
 
Upvote 0
that's just it...i don't think it was ever firing...rick sent me instructions on how to create one since i had never done it before, so perhaps we both missed a step???

Are you sure you right-click the correct tab in order to select Visual Basic from its popup menu? If you right-clicked the wrong tab, you would still get a code window to copy/paste into, but it would be the wrong one. The fact that you are not getting the MessageBoxes to appear means that the Column A you are typing into has no values in it... and that would happen only if you put the code in the wrong code window (or, possibly, that you are entering your values in the wrong worksheet)... I can think of no other reason what you would not see any MessageBoxes.
 
Upvote 0
forum
 
Upvote 0
When you are in the code window are any lines yellow?
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top