ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable Range Reference (https://www.excelbanter.com/excel-programming/319120-variable-range-reference.html)

Bob

Variable Range Reference
 
The following code doesn't work with a Method Range of object Global failed
error

For b = 6 To 15
Set rng = Range(Cells(3, b))
rng.Select
Selection.FormulaArray = "=PERCENTILE(R52C4:R" & c & "C4,R2C" & b &
")"
Next

But if I hard code the destination cell i.e. Set rng = Range("f3") it will
work for that one cell. What am I doing wrong in naming this range? Any
help is greatly appreciated.

Also, is there an On Exit event for a cell?

Tom Ogilvy

Variable Range Reference
 
Set rng = Range(Cells(3, b))

should be

Set rng = Cells(3, b)

--
Regards,
Tom Ogilvy

"Bob" wrote in message
...
The following code doesn't work with a Method Range of object Global

failed
error

For b = 6 To 15
Set rng = Range(Cells(3, b))
rng.Select
Selection.FormulaArray = "=PERCENTILE(R52C4:R" & c & "C4,R2C" & b

&
")"
Next

But if I hard code the destination cell i.e. Set rng = Range("f3") it

will
work for that one cell. What am I doing wrong in naming this range? Any
help is greatly appreciated.

Also, is there an On Exit event for a cell?




Ray Costanzo [MVP]

Variable Range Reference
 
Try:

For b = 6 to 15
Set rng = Cells(3,b)
rng.FormulaArray = "=PERCENTILE(R52C4:R" & c & "C4,R2C" & b & ")"
Next b

Ray at work


"Bob" wrote in message
...
The following code doesn't work with a Method Range of object Global

failed
error

For b = 6 To 15
Set rng = Range(Cells(3, b))
rng.Select
Selection.FormulaArray = "=PERCENTILE(R52C4:R" & c & "C4,R2C" & b

&
")"
Next

But if I hard code the destination cell i.e. Set rng = Range("f3") it

will
work for that one cell. What am I doing wrong in naming this range? Any
help is greatly appreciated.

Also, is there an On Exit event for a cell?




Bob

Variable Range Reference
 
Of course, thanks.

"Tom Ogilvy" wrote:

Set rng = Range(Cells(3, b))

should be

Set rng = Cells(3, b)

--
Regards,
Tom Ogilvy

"Bob" wrote in message
...
The following code doesn't work with a Method Range of object Global

failed
error

For b = 6 To 15
Set rng = Range(Cells(3, b))
rng.Select
Selection.FormulaArray = "=PERCENTILE(R52C4:R" & c & "C4,R2C" & b

&
")"
Next

But if I hard code the destination cell i.e. Set rng = Range("f3") it

will
work for that one cell. What am I doing wrong in naming this range? Any
help is greatly appreciated.

Also, is there an On Exit event for a cell?






All times are GMT +1. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com