Hello, I am hoping someone can help me with this....
I am trying to do create a macro to substitute part of a formula in column 'S', cells '1-254' on the worksheet “Original_Formula_Sheet" (so the range is 'S1:S254'). The formula essentially has a $503 absolute variable in it, and I need to replace it with a $753 in row 1. I have 254 rows to go through where the initial absolute variable needed to be replaced, but the value to be replaced increments with each subsequent line.
So what I am trying to do is list out all the variables to be changed and list out what they need to be changed to (eg: $503 to $753, $504 to $754,, etc...) on the worksheet "Values", columns 'A' and 'B', rows '1-254' (so the range is 'A1:B254')
When I have a macro built and try to run it I get a "Runtime Error '9': Subscript out of range"
Here is how I am trying to build the macro:
The error, when debugging, highlights the “Set myList = Worksheets(“Values”).Range(“A1:B254”)”.
Is there something that I am missing here... I am running Excel 2013
I am trying to do create a macro to substitute part of a formula in column 'S', cells '1-254' on the worksheet “Original_Formula_Sheet" (so the range is 'S1:S254'). The formula essentially has a $503 absolute variable in it, and I need to replace it with a $753 in row 1. I have 254 rows to go through where the initial absolute variable needed to be replaced, but the value to be replaced increments with each subsequent line.
So what I am trying to do is list out all the variables to be changed and list out what they need to be changed to (eg: $503 to $753, $504 to $754,, etc...) on the worksheet "Values", columns 'A' and 'B', rows '1-254' (so the range is 'A1:B254')
When I have a macro built and try to run it I get a "Runtime Error '9': Subscript out of range"
Here is how I am trying to build the macro:
Code:
Sub Replace()
Dim myList, myRange
Set myList = Worksheets(“Values”).Range("A1:B254")
Set myRange = Worksheets(“Original_Formula_Sheet”).Range("S4:S254")
For Each cel In myList.Columns(1).Cells
myRange.Replace What:=cel.Value, Replacement:=cel.Offset(0, 1).Value, LookAt:=xlWhole
Next cel
End Sub
The error, when debugging, highlights the “Set myList = Worksheets(“Values”).Range(“A1:B254”)”.
Is there something that I am missing here... I am running Excel 2013