Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default 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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default 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.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default 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.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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.


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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.



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default 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.





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column Data to Appear as Column Headings in Another Sheet Monk[_2_] Excel Discussion (Misc queries) 3 November 27th 08 09:47 PM
Worksheet has numeric column headings. Change to alpha headings? Be Frank Excel Discussion (Misc queries) 1 June 18th 08 04:22 PM
Column headings to numbers and row headings to alphabets? Juliana Excel Discussion (Misc queries) 2 May 9th 08 05:58 PM
Can I invert a table so row headings are now column headings etc Sharon Excel Worksheet Functions 3 February 10th 05 07:28 PM
In Excel how to make Column Values to Column Headings JP Excel Programming 2 October 22nd 04 11:18 PM


All times are GMT +1. The time now is 11:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"