ClimoC
Well-known Member
- Joined
- Aug 21, 2009
- Messages
- 584
Greetings
My FormulaArray is too long - the dreaded +255 characters limit coming into effect.
I have tried two different workarounds with mixed results.
First I tried splitting the formula (a long If, ISERROR, MATCH, INDEX function with multiple criteria) into two parts, declaring each part as a string, then placing the first part in the cell (with 'X-X-X' concatenated on the end) and running a .replace on the X-X-X with the second part. Didn't work. I never did find out why it didn't work, because when I declared the 2nd string as 300 letter 'A's, it did the replace fine - but when I tried putting the 2nd part of the formula in there, the macro ran with no problems but didn't do the replace. When I manually tried doing the replace, it gave me a very ambigious "Your formula has an error" or something stupid like that (and wouldn't paste and highlight the error).
The second method I tried was again setting parts as strings, and then using a Len(String1) +1 and then concatenating the second part on (something I found on another site). That seemed to work (kind of) except that instead of doing a series of match,index etc and returning the value I was after (a string of text from the pertinent cell in another workbook), all I got was "1420". Apparently, on their own, String 1 = 142 and string2 = 0. Don't know where it's getting that from
So I've decided the best thing to do is have the macro do all the work, and then just paste the values. Problem is, this is a bit too complex for me and I was wondering if someone could kindly assist me in turning this formulaarray into VBA.
The full formulaarray is:
'wb1' is a workbook.name string
's' is a worksheet.name string
The two tables that this is to move data between are identical. What is not quite identical are two tables used for the criteria. One is a complete table with all info, the other is a simplified version with the same data but fewer columns.
I'd also just like to point out that I'm certain this is how this needs to be done. The module containing this will be exported into 13 different workbooks, so that each of those workbooks can send information back to the master workbook.
One last thing, the formulaarray is being used in this procedure:
My FormulaArray is too long - the dreaded +255 characters limit coming into effect.
I have tried two different workarounds with mixed results.
First I tried splitting the formula (a long If, ISERROR, MATCH, INDEX function with multiple criteria) into two parts, declaring each part as a string, then placing the first part in the cell (with 'X-X-X' concatenated on the end) and running a .replace on the X-X-X with the second part. Didn't work. I never did find out why it didn't work, because when I declared the 2nd string as 300 letter 'A's, it did the replace fine - but when I tried putting the 2nd part of the formula in there, the macro ran with no problems but didn't do the replace. When I manually tried doing the replace, it gave me a very ambigious "Your formula has an error" or something stupid like that (and wouldn't paste and highlight the error).
The second method I tried was again setting parts as strings, and then using a Len(String1) +1 and then concatenating the second part on (something I found on another site). That seemed to work (kind of) except that instead of doing a series of match,index etc and returning the value I was after (a string of text from the pertinent cell in another workbook), all I got was "1420". Apparently, on their own, String 1 = 142 and string2 = 0. Don't know where it's getting that from
So I've decided the best thing to do is have the macro do all the work, and then just paste the values. Problem is, this is a bit too complex for me and I was wondering if someone could kindly assist me in turning this formulaarray into VBA.
The full formulaarray is:
Code:
"=IF(ISERROR(MATCH(1,([" & wb1 & "]" & s & "!R6C5:R100C5=RC9)*([" & wb1 & "]" & s & "!R6C9:R100C9=RC14)*([" & wb1 & "]" & s & "!R6C6:R100C6=RC10),0)),"""",INDEX([" & wb1 & "]" & s & "!R6C15:R100C15,MATCH(1,([" & wb1 & "]" & s & "!R6C5:R100C5=RC9)*([" & wb1 & "]" & s & "!R6C9:R100C9=RC14)*([" & wb1 & "]" & s & "!R6C6:R100C6=RC10),0)))"
'wb1' is a workbook.name string
's' is a worksheet.name string
The two tables that this is to move data between are identical. What is not quite identical are two tables used for the criteria. One is a complete table with all info, the other is a simplified version with the same data but fewer columns.
I'd also just like to point out that I'm certain this is how this needs to be done. The module containing this will be exported into 13 different workbooks, so that each of those workbooks can send information back to the master workbook.
One last thing, the formulaarray is being used in this procedure:
Code:
Set destr1 = Range("AA6:AA500")
For Each Cell In destr1
If Cell.Offset(0, -22).Value = wb.ActiveSheet.Range("C6").Value Then
With Cell
.FormulaArray = "=IF(ISERROR(MATCH(1,([" & wb1 & "]" & s & "!R6C5:R100C5=RC9)*([" & wb1 & "]" & s & "!R6C9:R100C9=RC14)*([" & wb1 & "]" & s & "!R6C6:R100C6=RC10),0)),"""",INDEX([" & wb1 & "]" & s & "!R6C15:R100C15,MATCH(1,([" & wb1 & "]" & s & "!R6C5:R100C5=RC9)*([" & wb1 & "]" & s & "!R6C9:R100C9=RC14)*([" & wb1 & "]" & s & "!R6C6:R100C6=RC10),0)))"
End With
End If
Next
Last edited: