Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
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 |
#2
![]() |
|||
|
|||
![]()
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 -----Original Message----- 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 . |
#3
![]() |
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Date formula | Excel Discussion (Misc queries) | |||
How to extract month number from month name | Excel Discussion (Misc queries) |