Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple Range Syntax Question

0 views
Skip to first unread message

John V

unread,
Nov 23, 2009, 8:50:01 PM11/23/09
to
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

Tim Williams

unread,
Nov 23, 2009, 9:02:27 PM11/23/09
to

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

Tim

Barb Reinhardt

unread,
Nov 23, 2009, 9:24:01 PM11/23/09
to

Barb Reinhardt

unread,
Nov 23, 2009, 9:26:02 PM11/23/09
to
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

unread,
Nov 23, 2009, 10:06:01 PM11/23/09
to
As the saying goes, it's simple if you know how, impossible if you don't.

Thanks very much, John


0 new messages