Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Simple Range Syntax Question

Right now, I have the following line of code in a macro:

Range("B6:B129").FormulaR1C1 = _
"=YEAR(RC[-1])&TEXT(MONTH(RC[-1]),""00"")&TEXT(DAY(RC[-1]),""00"")"

Now I want to generalize the reference to select, starting in cell B6, a
range that is X rows long and Y rows wide (X and Y determined elsewhere).

How to I change this code? Thanks, John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Simple Range Syntax Question


Range("B6").Resize(numRows, numCols).FormulaR1C1 = ....

Tim


On Nov 23, 5:50*pm, John V wrote:
Right now, I have the following line of code in a macro:

Range("B6:B129").FormulaR1C1 = _
* * * * "=YEAR(RC[-1])&TEXT(MONTH(RC[-1]),""00"")&TEXT(DAY(RC[-1]),""00"")"

Now I want to generalize the reference to select, starting in cell B6, a
range that is X rows long and Y rows wide (X and Y determined elsewhere).

How to I change this code? Thanks, John


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Simple Range Syntax Question

As the saying goes, it's simple if you know how, impossible if you don't.

Thanks very much, John


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Simple Range Syntax Question


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Simple Range Syntax Question

I'm not sure if the last post went through, so will repost

Dim myRange as Excel.Range

Set myRange = Range("B6").Resize(X,Y) 'assumes that X and Y are defined

myRange.FormulaR1C1 = _
"=TEXT(RC[-1]),""yyyymmdd"")"

I'm thinking your formula may change if you resize the range, but this
answers the question that was asked.
--
HTH,

Barb Reinhardt



"John V" wrote:

Right now, I have the following line of code in a macro:

Range("B6:B129").FormulaR1C1 = _
"=YEAR(RC[-1])&TEXT(MONTH(RC[-1]),""00"")&TEXT(DAY(RC[-1]),""00"")"

Now I want to generalize the reference to select, starting in cell B6, a
range that is X rows long and Y rows wide (X and Y determined elsewhere).

How to I change this code? Thanks, John



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
question about syntax in a simple macro... Dave F Excel Discussion (Misc queries) 3 November 3rd 06 02:12 PM
Range Question (very simple) narutard[_4_] Excel Programming 0 July 14th 05 07:52 PM
Simple question - Named Range in Macro wammer[_6_] Excel Programming 1 August 25th 04 12:39 AM
Simple range reference question? Mike Excel Programming 6 February 26th 04 08:04 PM
need help with simple syntax error Gwill Excel Programming 1 July 15th 03 08:24 AM


All times are GMT +1. The time now is 11:15 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"