2

This is my first time using the replace function in an attempt to bypass the 255 character limit within an array. For some reason the macro will put theFormulaPart1 in the code but then it says my formula contains an error and it does not replace the X_X_X with theFormulaPart2. This is also my first time utilizing one of these sites for help with vba so I am sorry in advance if my formatting is sloppy. Thanks for all your help!

Sub PortNum()
'
' PortNum Macro
'

'
Dim theFormulaPart1 As String
Dim theFormulaPart2 As String

theFormulaPart1 = "=INDEX('S:\CREDIT SHARED\Credit Files\2. C&I CREDIT      FILES\~C&I Spreading Model Data\[C&I Portfolio Data.xlsx]Page1_1'!R7C3:R1000C3, X_X_X)"
theFormulaPart2 = "LARGE(IF(R346C11='S:\CREDIT SHARED\Credit Files\2. C&I CREDIT FILES\~C&I Spreading Model Data\[C&I Portfolio Data.xlsx]Page1_1'!R7C1:R1000C1, ROW(R7C1:R1000C1)-ROW(R7C1)+1), ROW(R[-346])))"

With ActiveSheet.Range("O347")
.FormulaArray = theFormulaPart1
.Replace "X_X_X)", theFormulaPart2
End With

Range("O347").Select
Selection.AutoFill Destination:=Range("O347:O359"), Type:=xlFillDefault
Range("O347:O359").Select
End Sub
Graham
  • 21
  • 1

1 Answers1

0

The reason is, that the formulas have to make sense to be replaced at any time. So you can't replace with Strings. I made a function that works for english function in A1-notation. I originally recorded the macro using absolute references but the second part of the code that you insert cannot be that notation, it must utilize the actual code that you should expect to see in the cell after the macro has performed its actions.

ArrayFormula More than 255 Characters .Replace Not Working

Community
  • 1
  • 1
Graham
  • 21
  • 1
  • 1
    Welcome to the site! Would you please add the working code to this answer (*not* to your question) so that others can see how you solved the problem? Thanks very much! – cxw Apr 12 '16 at 13:14