Paul Dodson
New Member
Hello -
I'm fairly new to VBA, and attempting to get my array formula consolidated to within the 255 character limit has taken me hours, only to end up still unsuccessful. Below is the code I currently have:
The normal array formula I am trying to break up is below (with the exception of row 2000 being replaced by lastrowdata):
Can anybody help me write this correctly? I've been researching for a while, and I can't seem to get solve the issue.
I'm fairly new to VBA, and attempting to get my array formula consolidated to within the 255 character limit has taken me hours, only to end up still unsuccessful. Below is the code I currently have:
Code:
Dim FormulaPart1 As String
Dim FormulaPart2 As String
Dim FormulaPart3 As String
Dim lastrowdata As Long
lastrowdata = Cells(Cells.Rows.Count, "B").End(xlUp).Row
FormulaPart1 = "=SUM(IF((RC1=Test!R2C11:R" & lastrowdata & "C11)*(Test!R2C22:R" & lastrowdata & "C22<DATE(2016,2,1))*(Test!R2C22:R" & lastrowdata & "C22>DATE(2015,12,31)),""1+YYYY"",""""))"
FormulaPart2 = "1/COUNTIFS(Test!R2C11:R" & lastrowdata & "C11,RC1,Test!R2C2:R" & lastrowdata & "C2,Test!R2C2:R" & lastrowdata & "C2,+ZZZZ)"
FormulaPart3 = "Test!R2C22:R" & lastrowdata & "C22,""<""&DATE(2016,2,1),Test!R2C22:R" & lastrowdata & "C22,"">""&DATE(2015,12,31)),0))"
With ActiveSheet.Range("B4")
.FormulaArray = FormulaPart1
.Replace """1+YYYY"",""""))", FormulaPart2, lookat:=xlPart
.Replace "+ZZZZ)", FormulaPart3, lookat:=xlPart
End With
The normal array formula I am trying to break up is below (with the exception of row 2000 being replaced by lastrowdata):
Code:
{=SUM(IF(($A4=Test!$K$2:$K$2000)*(Test!$V$2:$V$2000<DATE(2016,2,1))*(Test!$V$2:$V$2000>DATE(2015,12,31)),1/COUNTIFS(Test!$K$2:$K$2000,$A4,Test!$B$2:$B$2000,Test!$B$2:$B$2000,Test!$V$2:$V$2000,"<"&DATE(2016,2,1),Test!$V$2:$V$2000,">"&DATE(2015,12,31)),0))}
Can anybody help me write this correctly? I've been researching for a while, and I can't seem to get solve the issue.