How to update MonthView for current year

Dunner72

New Member
Joined
Aug 31, 2014
Messages
3
I made an attendance register (using Excel 2013) for my classroom about 2 years ago.

It uses MonthView to select dates from a form for new student admissions.
My problem NOW, is that the Monthview is still stuck in 2014 every time the form pops open. How can I change the MonthView so it reflect the current year and month when it opens?


I am pasting all of my code below.
Thanks for any suggestions.



Code:
Private Sub cmdEnterData_Click()
Dim i As Integer
i = 2
While ThisWorkbook.Worksheets("Admissions").Range("B" & i).Value <> ""
i = i + 1


Wend
ThisWorkbook.Worksheets("Admissions").Range("D" & i).Value = MonthView1.Value
ThisWorkbook.Worksheets("Admissions").Range("B" & i).Value = ComboBox2.Value
ThisWorkbook.Worksheets("Admissions").Range("C" & i).Value = ComboBox1.Value


 Range("AC38").Select
    i = 1 'set as the first ID
     Do Until ActiveCell.Value = Empty
        ActiveCell.Offset(1, 0).Select 'move down 1 row
        'keep a count of the ID for later use
    Loop


    'Populate the new data values into the 'Data' worksheet.
    ActiveCell.Value = Me.MonthView1.Value


    Me.MonthView1.Value = Empty
    Me.ComboBox2.Text = Empty
    Me.ComboBox1.Text = Empty
 


    Me.ComboBox2.SetFocus
    Unload Me


End Sub




Private Sub MonthView1_DateClick(ByVal DateClicked As Date)


End Sub


Private Sub UserForm_Initialize()
Dim sht As Worksheet, txt As String
For Each sht In ActiveWorkbook.Sheets
      Me.ComboBox2.AddItem sht.Name
Next sht


    Me.ComboBox1.AddItem "Internal Admission"
    Me.ComboBox1.AddItem "External Admission"


'ComboBox1 = List.Array("External Admission", "Internal Admission")
    


End Sub


Private Sub cmdClose_Click()
    'close the form (itself)
    Unload Me
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Within your Userform_Initialize sub add this:
Code:
[FONT=&quot][COLOR=#000088]If[/COLOR][COLOR=black]IsDate(ActiveCell.Value) [/COLOR][COLOR=#000088]Then[/COLOR][/FONT]
[COLOR=black][FONT=&quot]    Me.MonthView1.Value= ActiveCell.Value
Else
    Me.MonthView1.Value = Now()[/FONT][/COLOR]
[COLOR=#000088][FONT=&quot]EndIf[/FONT][/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top