In VBA, you can create a collection of values or array by using Array function. To create an array by using array function, you need to write its elements in parentheses and separate each element by comma. The lowest index of the array is 0 and the highest index is equal to the number of its elements minus one.
You can check the lowest index and highest index of the array by using LBound(array) and UBound(array) functions.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim mons As Variant
Dim i As Integer
mons = Array("January", "Frebruary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
For i = LBound(mons) To UBound(mons)
Cells(i + 1, 1) = mons(i) 'dispaly months of the year in the current worksheet
If Month(Now) = i + 1 Then
Cells(i + 1, 1).Interior.Color = RGB(16, 100, 200) 'highlight the current month
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: