VBA Insert formula
i was recently using the following vba code to insert a formula and it worked fine but i've had to change the formula and the new formula wont work, just says 'Application-defined or Object defined error.
I believe it's because the new formula contains a custom function but am unsure.
Old working code:
Range("O12").Formula = "=(IF(ISBLANK(C12),"""",IF(ISERROR(VLOOKUP(C12,IND IRECT(""'""&($AG$2-1)&""'!$C:$AG""),13,FALSE)),N12,VLOOKUP(C12,INDIRE CT(""'""&($AG$2-1)&""'!$C:$AG""),13,FALSE))))"
New Not working code:
Range("O12").Formula = "=IF(ISBLANK(C12),"",IF(ISERROR(VLOOKUP(C12,INDIRE CT(PrevSheetName()&""!$C:$AG""),13,FALSE)),N12,VLO OKUP(C12,INDIRECT(PrevSheetName()&""!$C:$AG""),13, FALSE))))"
Last note:
The new formula does work when manually entered into the required cell but fails when vba is instructed to put the formula into a cell.
Any help would be appreciated, this is the last element of my workbook then it's complete.
|