Q: using vba's MONTH

  • Thread starter Thread starter John
  • Start date Start date
J

John

Why does this code return a value of "2005"? It needs to return "2004".
(range "a4" equals mar-13-2004)

With Range("a9")
If (Month(Range("a4") > 6)) Then
.Value = Year(Range("a4")) + 1
Else
.Value = Year(Range("a4"))
End If
End With
 
Hi John

You have your parenthesis wrong, change to


With Range("a9")
If Month(Range("a4")) > 6 Then
.Value = Year(Range("a4")) + 1
Else
.Value = Year(Range("a4"))
End If
End With

***** Posted via: http://www.ozgrid.com
Excel Templates, Training & Add-ins.
Free Excel Forum http://www.ozgrid.com/forum *****
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top