Hi
I have a workbook that contains 12 sheets named after the months. The
code below is attached to a command button on a form and opens the
worksheet named after the current month (eg, January, if I used the
form today). How can I adapt the code that the button actually looks
for the previous month. I assume it will mean altering the 'Now'
area...? For the sake of argument, all references to CurrMonth would be
'PrevMonth.' Also, 'MonthPick' is the name of the userform.
Private Sub CommandButton1_Click()
Dim CurrMonth As String
CurrMonth = Format(Now, "mmmm")
Sheets(CurrMonth).Select
MonthPick.Hide
End Sub
Thanks in advance
Steve
Doug Robbins - 23 Jan 2005 14:04 GMT
Use Format(DateAdd("m", -1, Now), "mmmm")
Note, that this is a Word newsgroup, not one for Excel.

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Hi
>
[quoted text clipped - 16 lines]
>
> Steve
crankylemming@aol.com - 23 Jan 2005 17:21 GMT
Thanks for replying and for your help, Doug.
Sorry, I don't know why I posted it here; in my head I was at the
public.excel group. sorry about that.
Steve