UserForm to select current month or earlier

S

Steve

Hi

I'm wondering if this can be done...?

I have a workbook which contains, among others, 12 sheets named after
the months January through to December.

I would like to have a UserForm which gives a buttonclick choice:
Current Month or Last Month. Is it possible to have the each button
open up the correct month, ie Current Month would open ("January") and
Last Month open ("December")? If so, does anyone have any suggestions
as to how?

TIA

Steve
 
J

Jason Morin

Instructions on building a User Form is difficult, but not
for an InputBox. It's not as pretty, but here's something
to start with:

Sub SelectMonth()
Dim sMonth As String
Dim CurrMonth As String
sMonth = InputBox("1 for current month," & _
" 2 for last month")
If sMonth = "" Then Exit Sub
Select Case sMonth
Case 1
CurrMonth = Format(Now, "mmmm")
Sheets(CurrMonth).Select
Case 2
Sheets("December").Select
Case Else
MsgBox ("Please insert 1 or 2!")
End Select
End Sub

---
Insert this into a standard module.

HTH
Jason
Atlanta, GA
 
S

Steve

Jason

Thanks a lot for replying. I'm playing about with the code, and I've
got a userform button working to select the current month with :

Private Sub CommandButton1_Click()
Dim CurrMonth As String
CurrMonth = Format(Now, "mmmm")
Sheets(CurrMonth).Select
MonthPick.Hide
End Sub

I'm relatively comfortable with constructing UserForms; it's the VB
that goes with them that gets me :)

Is there a quick'n'easy way of VBing 'Now' - 1 (month)? If not, your
solution works excellently, thanks, but I'm still hoping I might get
this done on a form.

TIA

Steve
 
Top