davesexcel.com

Excel information

Most Popular Excel Questions

Create a list of months excel VBA

Posted by davesexcel on March 29, 2012 at 9:05 PM

Create a list of months for each row in Column A


Sub ListMonthInRow()

Dim c As Long

For c = 1 To 12

Cells(c, 1) = Format(DateSerial(2012, c, 1), "mmmm")

Next c

End Sub

Create a list of months In Row 1


Sub ListMonthInColumn()

Dim c As Long

For c = 1 To 12

Cells(1, c) = Format(DateSerial(2012, c, 1), "mmmm")

Next c

End Sub

Create a list of months in a combobox from the controls tool bar


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim c As Long

    For c = 1 To 12

        ComboBox1.AddItem Format(DateSerial(2012, c, 1), "mmmm")

    Next c

 

 Create a list of months in a combobox in a userform


Private Sub UserForm_Initialize()

    Dim c As Long

    

    For c = 1 To 12

    

        ComboBox1.AddItem Format(DateSerial(2012, c, 1), "mmmm")

    Next c

End Sub

 

 


 

 


 

 


Categories: None

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

0 Comments