pablo_max3045
New Member
- Joined
- May 15, 2017
- Messages
- 33
Hello all,
I know that you cannot have an array over 255 characters when using VBA (for whatever reason) and that the solution is to split the formula into two variables.
Then, use a replace function on some random characters in the first formula with the 2nd variable.
However, I have no luck at all with it.
This is my code until now.
The first bit gets pasted in there, but the replacement doesnt happen.
I am sure I am doing something basic wrong, but I just dont know what it would be.
I actually need to replace [""REMOVE"")] and then stick the second part on, but excel complains if i try to search for that.
I know that you cannot have an array over 255 characters when using VBA (for whatever reason) and that the solution is to split the formula into two variables.
Then, use a replace function on some random characters in the first formula with the 2nd variable.
However, I have no luck at all with it.
This is my code until now.
Code:
Sub Macro10()
Dim formula1 As String
Dim formula2 As String
formula1 = "=IFERROR(INDEX(Comp_Against!R2C2:R2569C8,MATCH(New_Plan!RC2&New_Plan!RC1,Comp_Against!R2C2:R1707C2&Comp_Against!R2C1:R1918C1,0),1),""REMOVE"")"
formula2 = ",IFERROR(INDEX(Comp_Against!R2C2:R2569C8,MATCH(New_Plan!RC13&New_Plan!RC1,Comp_Against!R2C2:R1707C2&Comp_Against!R2C1:R1918C1,0),1),""no"")))"
Range("N2").Select
With ActiveSheet.Range("N2")
.FormulaArray = formula1
.Replace "REMOVE", formula2
End With
'working formula when copied into excel minus R1C1 notation
'"=IFERROR(INDEX(Comp_Against!R2C2:R2569C8,MATCH(New_Plan!RC2&New_Plan!RC1,Comp_Against!R2C2:R1707C2&Comp_Against!R2C1:R1918C1,0),1),IFERROR(INDEX(Comp_Against!R2C2:R2569C8,MATCH(New_Plan!RC13&New_Plan!RC1,Comp_Against!R2C2:R1707C2&Comp_Against!R2C1:R1918C1,0),1),""no""))"
End Sub
I am sure I am doing something basic wrong, but I just dont know what it would be.
I actually need to replace [""REMOVE"")] and then stick the second part on, but excel complains if i try to search for that.