Dear Friends,
The purpose of the below code is to enter formulas in the range of cells
It works fine for non Array Formulas for Columns R & S
But it does not work for columns AB, AC & AD because of array formuals I guess - or is it something else ?? because I can't the see the formula results
Can someone pls check
The purpose of the below code is to enter formulas in the range of cells
It works fine for non Array Formulas for Columns R & S
But it does not work for columns AB, AC & AD because of array formuals I guess - or is it something else ?? because I can't the see the formula results
Can someone pls check
VBA Code:
Private Sub ApplyFormulaToRangeOrders()
Dim ws As Worksheet
Dim formulaRange As Range
' Assign the sheet to a variable
Set ws = Sheets("ORDERS")
' Apply formulas to PO & Article Concatenated
Set formulaRange = ws.Range("R2:R1800")
formulaRange.Formula = "=IF(ISBLANK(B2),"""",IF(B2<>B1,A2,IF(ISNUMBER(SEARCH(A2,R1)),R1,R1&"" - ""&A2)))"
Set formulaRange = ws.Range("S2:S1800")
formulaRange.Formula = "=IF(ISBLANK(B2),"""",IF(B2<>B1,F2,IF(ISNUMBER(SEARCH(F2,S1)),S1,S1&"" - ""&F2)))"
' Now converting formulas to values
ws.Range("R2:S1800").Value = ws.Range("R2:S1800").Value
' Apply formulas to the DPI & FRI Columns
Set formulaRange = ws.Range("AB2:AB1800")
formulaRange.FormulaArray = "=IFERROR(INDEX(fri_dpi_labtest_date,MATCH(1,($A2=fri_dpi_labtest_po)*(""FRI 1""=fri_dpi_labtest_category),0)),"""")"
Set formulaRange = ws.Range("AC2:AC1800")
formulaRange.FormulaArray = "=IFERROR(INDEX(fri_dpi_labtest_date,MATCH(1,($A2=fri_dpi_labtest_po)*(""FRI 2""=fri_dpi_labtest_category),0)),"""")"
Set formulaRange = ws.Range("AD2:AD1800")
formulaRange.FormulaArray = "=IFERROR(INDEX(fri_dpi_labtest_date,MATCH(1,($A2=fri_dpi_labtest_po)*(""FRI 3""=fri_dpi_labtest_category),0)),"""")"
End Sub