#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default R1C1 riddle

Can anyone explain why the first line of code is 'skipping rows' and
the second and third are not? What am I missing?

Range("a1.b10").Formula = Array("=rc[1]", "=""Row: ""&ROW()")

Range("a1.b10").FormulaArray = Array("=rc[1]", "=""Row: ""&ROW()")
Range("c1.c10").Formula = "=""Row: ""&row(rc[1])"

Checked in Excel 2000 and Excel XP.

Regards,
Andre

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default R1C1 riddle

Yes, this is a quirk I came across a while back, and had to use a different
method to get around it. It appears that filling a range with a formula
automatically updates the cell reference much like entering a formula in a
cell then dragging it downward. I've never used the "=rc[1]" syntax but it
appears that the [1] means offset by one, and the automatic offset update of
filling the range is why the offset becomes 1, 3, 5.

I tried these statements stepping through the debugger to see how the
formulas are entered:

Private Sub Workbook_Open()

Range("A1:B2").ClearContents
Range("A1:A2").Formula = "=B1"

Range("A1:B2").ClearContents
Range("A1:A2").Formula = Array("=B1", "=D1")

Range("A1:B2").ClearContents
Range("A1:A2").FormulaArray = "=B1"

Range("A1:B2").ClearContents
Range("A1:A2").FormulaArray = Array("=B1", "=D1")

Range("A1:B2").ClearContents
Range("A1:B1").Formula = "=B1"

Range("A1:B2").ClearContents
Range("A1:B1").Formula = Array("=B1", "=D1")

Range("A1:B2").ClearContents
Range("A1:B1").FormulaArray = "=B1"

Range("A1:B2").ClearContents
Range("A1:B1").FormulaArray = Array("=B1", "=D1")

End Sub

It seems like the Array("", "") statement fills across the row, i.e. the
range("A1:A2") receives only the first element of the Array(), which is
subsequently copied (and offset) downward. Try it and see if you follow what
it does.


"Scriptick" wrote:

Can anyone explain why the first line of code is 'skipping rows' and
the second and third are not? What am I missing?

Range("a1.b10").Formula = Array("=rc[1]", "=""Row: ""&ROW()")

Range("a1.b10").FormulaArray = Array("=rc[1]", "=""Row: ""&ROW()")
Range("c1.c10").Formula = "=""Row: ""&row(rc[1])"

Checked in Excel 2000 and Excel XP.

Regards,
Andre


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
XIRR and IRR riddle - Please Help! kevwags Excel Discussion (Misc queries) 1 February 9th 11 08:06 PM
help on Converting R1C1 to A1 and A1 to R1C1..tia sa2 temp Excel Discussion (Misc queries) 3 September 13th 07 08:31 AM
help on Converting R1C1 to A1 and A1 to R1C1..tia sa2 temp Excel Worksheet Functions 3 September 13th 07 08:31 AM
Help! I can't figure this riddle out guyinatshirt Excel Programming 5 November 20th 03 11:39 PM
r1c1 nath Excel Programming 1 August 19th 03 03:51 PM


All times are GMT +1. The time now is 12:23 PM.

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"