jsmith2094
New Member
- Joined
- Aug 19, 2021
- Messages
- 35
- Office Version
- 365
- Platform
- Windows
Hey everyone,
I have created a function :
what I need to do is to assign number to Column A from 1-12 then based on the cell value then display a mesgbox containing the month of the year so for example 1= january, 2= febuary and so on.....
I have attempted but think im way off lol
Any help would be apricated
I have created a function :
VBA Code:
Function Name_of_month(a)
Name_of_month = "Unknown"
If a = 1 Then Name_of_month = "January"
If a = 2 Then Name_of_month = "February"
If a = 3 Then Name_of_month = "March"
If a = 4 Then Name_of_month = "April"
If a = 5 Then Name_of_month = "May"
If a = 6 Then Name_of_month = "June"
If a = 7 Then Name_of_month = "July"
If a = 8 Then Name_of_month = "August"
If a = 9 Then Name_of_month = "September"
If a = 10 Then Name_of_month = "October"
If a = 11 Then Name_of_month = "November"
If a = 12 Then Name_of_month = "December"
End Function
what I need to do is to assign number to Column A from 1-12 then based on the cell value then display a mesgbox containing the month of the year so for example 1= january, 2= febuary and so on.....
I have attempted but think im way off lol
Code:
Sub Enumerate_all_months()
Dim A As Integer ' Create whole number variable
Dim b As String
For A = 1 To 12
Cells(A, 1) = A
Next
b = Name_of_month(A)
MsgBox b
End Sub
Any help would be apricated