Excel Agenda Sample
We created a calendar using class on the userform. There are hours and corresponding text boxes on the userform.
The desired date is selected from the calendar, the notes to be added for the date are entered on the text boxes and then saved in the relevant cells on the worksheet.
The calendar covers the dates from 2020 to 2025 and the calendar is created according to the system language of the user. Column A of the worksheet lists dates between 2020 and 2025 by day, month, and year. The hours are listed on the headers from column C to column P . In this way, notes can be created according to the hours.
VBA codes of userform “Save” button :
Private Sub CommandButton1_Click() Dim ara As Range Set ara = Sheets("data").Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Find(CDate(Calendar1.Value), , xlValues, xlWhole) If Not ara Is Nothing Then Sheets("data").Cells(ara.Row, 2).Value = TextBox5.Text For i = 6 To 18 Sheets("data").Cells(ara.Row, i - 3).Value = Controls("TextBox" & i).Text Next End If sor2 = MsgBox("The data were saved", vbInformation, " ") End Sub
If there is a note or record for the date and time, it is displayed in the relevant textbox on the userform. This note can be deleted or changed.
Multi-line data can be saved into sheet cells. If the recorded data consists of many rows, the cell height is adjusted accordingly. For this, we created a loop that consisted VBA Wrap Text property :
For y = 2 To 16 Sheets("data").Columns(y).EntireColumn.WrapText = True Next