View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Danny Danny is offline
external usenet poster
 
Posts: 148
Default Change Day to Month - VBA

Hi,

I got this macro from this NG to promt a password for a particular "day".
How do you change the macro to a particular "month and year".

from (#9/10/2007#) to Sep 2007
from (#9/11/2007#) to Oct 2007
from (#9/12/2007#) to Nov 2007

The format from vba help, "month(#9/10/2007#)" did not work.

Sub PWforDate()
Dim arrPwords(1 To 3, 1 To 2) As Variant
Dim strPWord As String

arrPwords(1, 1) = (#9/10/2007#)
arrPwords(2, 1) = (#9/11/2007#)
arrPwords(3, 1) = (#9/12/2007#)
arrPwords(1, 2) = 1234
arrPwords(2, 2) = 2345
arrPwords(3, 2) = 3456
strPWord = CStr(Application.VLookup(Date, arrPwords, 2, 0))
MsgBox strPWord
End Sub

Thank you.