How to use a variable placeholder to index rows? i.e. RyC7

KS_user

New Member
Joined
Jun 10, 2015
Messages
44
Each time this loop executes, I want the formula 'ActionLevel' to move down another row. So I want to use the y variable as the row index, but this won't work. VBA doesn't give me an error, but the function itself doesn't work (on the cells it's supposed to calculate, a #VALUE appears)

x = 7
F = 17
y = 10

Do While x < F
Cells(i, j) = x
Cells(i, k).FormulaR1C1 = "=EDS_Value(Esc_CPD_pH, RC[-1])"
Cells(i, l).FormulaR1C1 = "=ActionLevel(RC[-1], Limits_Page!RyC7:R17C16, 9)"
x = x + 0.020833338
y=y+1
i = i + 1
count = count + 1
Loop

Thanks!!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Cells(i, l).FormulaR1C1 = "=ActionLevel(RC[-1], Limits_Page!RyC7:R17C16, 9)"
Try the above line of code like this instead...

Cells(i, l).FormulaR1C1 = "=ActionLevel(RC[-1], Limits_Page!R" & y & "C7:R17C16, 9)"

The way you had it, the y was inside a quoted text constant... VB cannot see that as anything more than a single letter character that way... you have to concatenate the variable into the text so that VB can see it is a variable. Think about what you did originally... if that would have worked, then how would you ever have been able to include the letter "y", like in the word "day" for instance, without VB changing it as well?
 
Upvote 0

Forum statistics

Threads
1,203,224
Messages
6,054,234
Members
444,711
Latest member
Stupid Idiot

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top