ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Months as Column Headings (https://www.excelbanter.com/excel-programming/420831-months-column-headings.html)

Exceller

Months as Column Headings
 
I would love have a script that enters the months of the year as column
headings. I would like it to enter "January", through "December" (all 12
months) beginning in the cell I select. So, If I select cell "B4" and run
the script, then "January" will be entered in B4, "February" will be entered
in cell C4, "March" in D4, and so on, through December.

Thanks.

Bernard Liengme

Months as Column Headings
 
Sub tryme()
mymonths = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec")
myrow = Selection.Row
mycol = Selection.Column
For j = 0 To 11
Cells(myrow, mycol) = mymonths(j)
mycol = mycol + 1
Next j
End Sub

I was too lazy to type full month names!
best wishes

--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Exceller" wrote in message
...
I would love have a script that enters the months of the year as column
headings. I would like it to enter "January", through "December" (all 12
months) beginning in the cell I select. So, If I select cell "B4" and run
the script, then "January" will be entered in B4, "February" will be
entered
in cell C4, "March" in D4, and so on, through December.

Thanks.




Mike H

Months as Column Headings
 
Hi,

Alt +F11 to open Vb editor, right click 'This Workbook' and insert module
and paste the code below in.

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
End Sub

Mike

"Exceller" wrote:

I would love have a script that enters the months of the year as column
headings. I would like it to enter "January", through "December" (all 12
months) beginning in the cell I select. So, If I select cell "B4" and run
the script, then "January" will be entered in B4, "February" will be entered
in cell C4, "March" in D4, and so on, through December.

Thanks.


Patrick Molloy[_2_]

Months as Column Headings
 
Function Months()
Dim i As Long
Dim m(1 To 12) As String
For i = 1 To 12
m(i) = Format((DateSerial(2008, i, 1)), "MMMM")
Next
Months = m

End Function

select 12 cells in a row and enter =Months() as an array formula



"Exceller" wrote:

I would love have a script that enters the months of the year as column
headings. I would like it to enter "January", through "December" (all 12
months) beginning in the cell I select. So, If I select cell "B4" and run
the script, then "January" will be entered in B4, "February" will be entered
in cell C4, "March" in D4, and so on, through December.

Thanks.


Jim Cone[_2_]

Months as Column Headings
 
Use a custom list instead.
--
Jim Cone
Portland, Oregon USA



"Exceller"
wrote in message
I would love have a script that enters the months of the year as column
headings. I would like it to enter "January", through "December" (all 12
months) beginning in the cell I select. So, If I select cell "B4" and run
the script, then "January" will be entered in B4, "February" will be entered
in cell C4, "March" in D4, and so on, through December.

Thanks.

Exceller

Months as Column Headings
 
It works perfectly--thanks. I forgot one thing...in the cell to the right of
"December" input "Full Year". Could you please show me how to put that into
the script? Thanks.

"Mike H" wrote:

Hi,

Alt +F11 to open Vb editor, right click 'This Workbook' and insert module
and paste the code below in.

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
End Sub

Mike

"Exceller" wrote:

I would love have a script that enters the months of the year as column
headings. I would like it to enter "January", through "December" (all 12
months) beginning in the cell I select. So, If I select cell "B4" and run
the script, then "January" will be entered in B4, "February" will be entered
in cell C4, "March" in D4, and so on, through December.

Thanks.


Mike H

Months as Column Headings
 
Will this do?

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
ActiveCell.Offset(, 12).Value = "Full Year"
End Sub

Mike

"Exceller" wrote:

It works perfectly--thanks. I forgot one thing...in the cell to the right of
"December" input "Full Year". Could you please show me how to put that into
the script? Thanks.

"Mike H" wrote:

Hi,

Alt +F11 to open Vb editor, right click 'This Workbook' and insert module
and paste the code below in.

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
End Sub

Mike

"Exceller" wrote:

I would love have a script that enters the months of the year as column
headings. I would like it to enter "January", through "December" (all 12
months) beginning in the cell I select. So, If I select cell "B4" and run
the script, then "January" will be entered in B4, "February" will be entered
in cell C4, "March" in D4, and so on, through December.

Thanks.


Rick Rothstein

Months as Column Headings
 
This is a slimmer version of your code...

Sub sonic()
With ActiveCell
.Value = "January"
.AutoFill Destination:=.Resize(1, 12)
.Offset(, 12).Value = "Full Year"
End With
End Sub

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
Will this do?

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
ActiveCell.Offset(, 12).Value = "Full Year"
End Sub

Mike

"Exceller" wrote:

It works perfectly--thanks. I forgot one thing...in the cell to the
right of
"December" input "Full Year". Could you please show me how to put that
into
the script? Thanks.

"Mike H" wrote:

Hi,

Alt +F11 to open Vb editor, right click 'This Workbook' and insert
module
and paste the code below in.

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
End Sub

Mike

"Exceller" wrote:

I would love have a script that enters the months of the year as
column
headings. I would like it to enter "January", through "December" (all
12
months) beginning in the cell I select. So, If I select cell "B4"
and run
the script, then "January" will be entered in B4, "February" will be
entered
in cell C4, "March" in D4, and so on, through December.

Thanks.



Mike H

Months as Column Headings
 
Neat, i never thought of resizing the range

Mike

"Rick Rothstein" wrote:

This is a slimmer version of your code...

Sub sonic()
With ActiveCell
.Value = "January"
.AutoFill Destination:=.Resize(1, 12)
.Offset(, 12).Value = "Full Year"
End With
End Sub

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
Will this do?

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
ActiveCell.Offset(, 12).Value = "Full Year"
End Sub

Mike

"Exceller" wrote:

It works perfectly--thanks. I forgot one thing...in the cell to the
right of
"December" input "Full Year". Could you please show me how to put that
into
the script? Thanks.

"Mike H" wrote:

Hi,

Alt +F11 to open Vb editor, right click 'This Workbook' and insert
module
and paste the code below in.

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
End Sub

Mike

"Exceller" wrote:

I would love have a script that enters the months of the year as
column
headings. I would like it to enter "January", through "December" (all
12
months) beginning in the cell I select. So, If I select cell "B4"
and run
the script, then "January" will be entered in B4, "February" will be
entered
in cell C4, "March" in D4, and so on, through December.

Thanks.




Exceller

Months as Column Headings
 
How can I take this script that you wrote and add the following instructions
to it. Here's your code:

Sub sonic()
With ActiveCell
.Value = "January"
.AutoFill Destination:=.Resize(1, 12)
.Offset(, 12).Value = "Full Year"
End With
End Sub

What I'd like to do is actually make that the second instruction. The code
that I would like added takes the value in the ActiveCell and copies it
rightward to the next 11 adjacent cells and adds "Full Year" in the last
adjacent cell. After that is completed THEN the instructions above kick in.

So, if I enter "2009 Budget" into cell B5 and execute the macro "2009
Budget" (or whatever the value is in that cell) will be copied across the
next 11 adjacent cells and "Full Year" would be added at the end, THEN the
script above executes, adding "January" into the cell ABOVE the ActiveCell
(B4) and then autofills those adjacent cells and puts "Full Year" at the end.

Thanks.

"Rick Rothstein" wrote:

This is a slimmer version of your code...

Sub sonic()
With ActiveCell
.Value = "January"
.AutoFill Destination:=.Resize(1, 12)
.Offset(, 12).Value = "Full Year"
End With
End Sub

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
Will this do?

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
ActiveCell.Offset(, 12).Value = "Full Year"
End Sub

Mike

"Exceller" wrote:

It works perfectly--thanks. I forgot one thing...in the cell to the
right of
"December" input "Full Year". Could you please show me how to put that
into
the script? Thanks.

"Mike H" wrote:

Hi,

Alt +F11 to open Vb editor, right click 'This Workbook' and insert
module
and paste the code below in.

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
End Sub

Mike

"Exceller" wrote:

I would love have a script that enters the months of the year as
column
headings. I would like it to enter "January", through "December" (all
12
months) beginning in the cell I select. So, If I select cell "B4"
and run
the script, then "January" will be entered in B4, "February" will be
entered
in cell C4, "March" in D4, and so on, through December.

Thanks.




Rick Rothstein

Months as Column Headings
 
Does this do what you want?

Sub sonic()
With ActiveCell
.Offset(-1).Value = "January"
.Offset(-1).AutoFill Destination:=.Offset(-1).Resize(1, 12)
.Resize(1, 12).Value = .Value
.Offset(-1, 12).Resize(2, 1).Value = "Full Year"
End With
End Sub

--
Rick (MVP - Excel)


"Exceller" wrote in message
...
How can I take this script that you wrote and add the following
instructions
to it. Here's your code:

Sub sonic()
With ActiveCell
.Value = "January"
.AutoFill Destination:=.Resize(1, 12)
.Offset(, 12).Value = "Full Year"
End With
End Sub

What I'd like to do is actually make that the second instruction. The
code
that I would like added takes the value in the ActiveCell and copies it
rightward to the next 11 adjacent cells and adds "Full Year" in the last
adjacent cell. After that is completed THEN the instructions above kick
in.

So, if I enter "2009 Budget" into cell B5 and execute the macro "2009
Budget" (or whatever the value is in that cell) will be copied across the
next 11 adjacent cells and "Full Year" would be added at the end, THEN the
script above executes, adding "January" into the cell ABOVE the ActiveCell
(B4) and then autofills those adjacent cells and puts "Full Year" at the
end.

Thanks.

"Rick Rothstein" wrote:

This is a slimmer version of your code...

Sub sonic()
With ActiveCell
.Value = "January"
.AutoFill Destination:=.Resize(1, 12)
.Offset(, 12).Value = "Full Year"
End With
End Sub

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
Will this do?

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
ActiveCell.Offset(, 12).Value = "Full Year"
End Sub

Mike

"Exceller" wrote:

It works perfectly--thanks. I forgot one thing...in the cell to the
right of
"December" input "Full Year". Could you please show me how to put
that
into
the script? Thanks.

"Mike H" wrote:

Hi,

Alt +F11 to open Vb editor, right click 'This Workbook' and insert
module
and paste the code below in.

Sub sonic()
ActiveCell.Value = "January"
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":" _
& ActiveCell.Offset(, 11).Address), Type:=xlFillDefault
End Sub

Mike

"Exceller" wrote:

I would love have a script that enters the months of the year as
column
headings. I would like it to enter "January", through "December"
(all
12
months) beginning in the cell I select. So, If I select cell "B4"
and run
the script, then "January" will be entered in B4, "February" will
be
entered
in cell C4, "March" in D4, and so on, through December.

Thanks.






All times are GMT +1. The time now is 08:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com