Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to record a macro that will take the value of a cell and autofill
the next cell to the right. The problem I have is that the cell references will be variable. To try to explain this better, I have a spreadsheet with columns for each month of the year that show values from another worksheet. At then end of each month, I want to create a new column to insert that month's data. No problems so far. Once the column is inserted, I am trying to put a heading at the top of the column (e.g. July 2005) by autofilling from the previous column (e.g. June 2005). But I cannot work out how to write my code so it will also work for August, September etc. Any help with this would be most appreciated. Thank you MMH |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try using the date function in the cell. Something similar to:
Range(YourRange).FormulaR1C1 = "=DATE(YEAR(RC[-1]),MONTH(RC[-1])+1,DAY(RC[-1]))" For a formula similar to: =DATE(YEAR(G1),MONTH(G1)+1,DAY(G1)) -- Damon Longworth Don't miss out on the 2005 Excel User Conference Sept 16th and 17th Stockyards Hotel - Ft. Worth, Texas www.ExcelUserConference.com "MMH" wrote in message ... I am trying to record a macro that will take the value of a cell and autofill the next cell to the right. The problem I have is that the cell references will be variable. To try to explain this better, I have a spreadsheet with columns for each month of the year that show values from another worksheet. At then end of each month, I want to create a new column to insert that month's data. No problems so far. Once the column is inserted, I am trying to put a heading at the top of the column (e.g. July 2005) by autofilling from the previous column (e.g. June 2005). But I cannot work out how to write my code so it will also work for August, September etc. Any help with this would be most appreciated. Thank you MMH |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you - that does exactly what I want it to.
MMH "Damon Longworth" wrote: Try using the date function in the cell. Something similar to: Range(YourRange).FormulaR1C1 = "=DATE(YEAR(RC[-1]),MONTH(RC[-1])+1,DAY(RC[-1]))" For a formula similar to: =DATE(YEAR(G1),MONTH(G1)+1,DAY(G1)) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
AutoFill a cell with a value | Excel Discussion (Misc queries) | |||
Autofill: Need to autofill one week block, (5) weekday only into cells. | Excel Discussion (Misc queries) | |||
autofill according to cell index. | Excel Discussion (Misc queries) | |||
Q. Autofill question: Can I autofill alpha characters like I can numbers? | Excel Programming | |||
Autofill months in cell | Excel Programming |