ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Assigning Variable Range (https://www.excelbanter.com/excel-discussion-misc-queries/149318-assigning-variable-range.html)

JMay

Assigning Variable Range
 
nrow = 8, so rrow = 5
but the below is not working -- What's wrong?

..... *** code **
nrow = Range("A65536").End(xlUp).Row + 1
rrow = nrow - 3
rrow = CInt(rrow)
Range("A" & nrow).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-rrow]C:R[-1]C)" <<< PROBLEM
Range("A2").EntireRow.Delete
Range("A1").Select


JMay

Assigning Variable Range
 
never mind, just tried the below, which worked..

ActiveCell.FormulaR1C1 = "=SUM(R[-" & rrow & "]C:R[-1]C)"

"JMay" wrote:

nrow = 8, so rrow = 5
but the below is not working -- What's wrong?

.... *** code **
nrow = Range("A65536").End(xlUp).Row + 1
rrow = nrow - 3
rrow = CInt(rrow)
Range("A" & nrow).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-rrow]C:R[-1]C)" <<< PROBLEM
Range("A2").EntireRow.Delete
Range("A1").Select



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

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