View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Steve Yandl[_3_] Steve Yandl[_3_] is offline
external usenet poster
 
Posts: 117
Default Get Month name from Date value in cell

What I've got below tested fine and tests to make sure the value that was
entered can be seen as a date.

'-------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 And Target.Cells.Count = 1 And _
IsDate(Target.Value) Then

Dim dteDate As Date
Dim strDate As String

strDate = CStr(Target.Value)
dteDate = CDate(strDate)
Range("A20").Value = Format(dteDate, "mmmm")

Else
Exit Sub
End If

End Sub

'-------------------------------------

Steve Yandl



"Chip Dukes" wrote in message
...
I'm trying to get the month from a date representation as follows ...

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 And Target.Cells.Count = 1 Then
Dim strDate As String
strDate = Format(Target.Value, "mmmm")
Range("A20").Value = strDate
Else
Exit Sub
End If

End Sub

The error I am getting is ... "Object Required"

on the ... strDate = Format(Target.Value, "mmmm") ...

line

by which I'm guessing Target.Value is not being seen as a date type ...

Any ideas as to how I could get the month from a value entered into a call
... the value will always be in the form 5/24/55 ... from which I need the
string "May"

Chip Dukes
(New to Excel programming)