Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Steve
 
Posts: n/a
Default UserForm to select current month or earlier

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   Report Post  
Jason Morin
 
Posts: n/a
Default

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   Report Post  
Steve
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date formula Mike R Excel Discussion (Misc queries) 7 January 20th 05 10:07 PM
How to extract month number from month name PM Excel Discussion (Misc queries) 2 January 19th 05 03:07 PM


All times are GMT +1. The time now is 09:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"