Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MMH MMH is offline
external usenet poster
 
Posts: 14
Default Autofill cell to right

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Autofill cell to right

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   Report Post  
Posted to microsoft.public.excel.programming
MMH MMH is offline
external usenet poster
 
Posts: 14
Default Autofill cell to right

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
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
AutoFill a cell with a value N1KO Excel Discussion (Misc queries) 1 March 30th 09 11:45 AM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
autofill according to cell index. honour Excel Discussion (Misc queries) 1 December 2nd 04 01:49 PM
Q. Autofill question: Can I autofill alpha characters like I can numbers? George[_22_] Excel Programming 5 August 7th 04 10:33 AM
Autofill months in cell paradise Excel Programming 1 November 24th 03 04:53 AM


All times are GMT +1. The time now is 11:59 AM.

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"