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
 

CalcSux78

Well-known Member
Joined
Oct 15, 2013
Messages
1,120
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]
 

Forum statistics

Threads
1,082,151
Messages
5,363,430
Members
400,736
Latest member
Aida

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top