Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Column Data to Appear as Column Headings in Another Sheet | Excel Discussion (Misc queries) | |||
Worksheet has numeric column headings. Change to alpha headings? | Excel Discussion (Misc queries) | |||
Column headings to numbers and row headings to alphabets? | Excel Discussion (Misc queries) | |||
Can I invert a table so row headings are now column headings etc | Excel Worksheet Functions | |||
In Excel how to make Column Values to Column Headings | Excel Programming |