hello Guys,
I have following code where I am trying to insert array formulas n same ranges in different sheets.
The code worked when I entered the formula in one cell in each sheet. But it gave ma an error and the line in red above gets highlighted in yellow when I added the next bit trying to copy one cell in the range below for all sheets.
What is it that I am doing wrong?
Regards
Asad
I have following code where I am trying to insert array formulas n same ranges in different sheets.
Code:
Sub RunSheets()Dim FormulaOneA As String, FormulaOneB As String, FormulaTwoA As String, FormulaTwoB As String, FormulaTwoC As String, FormulaThreeA As String, FormulaThreeB As String, FormulaThreeC As String
Dim FormulaFourA As String, FormulaFourB As String
Dim ws As Worksheet
Dim ar As Areas
For Each ws In Worksheets(Array("Sun Run Sheet", "Mon Run Sheet", "Tue Run Sheet", "Wed Run Sheet", "Thu Run Sheet", "Fri Run Sheet", "Sat Run Sheet"))
With ws.Range("A5:O170")
ws.Range("A5").FormulaArray = "=IFERROR(INDEX('Timetarget Roster Export'!$S$1:$S$3000,MATCH(1,('Timetarget Roster Export'!$D$1:$D$3000=$B$3)*('Timetarget Roster Export'!$B$1:$B$3000=B5),0)),"""")"
ws.Range("B5").FormulaArray = "=IFERROR(INDEX('Timetarget Roster Export'!$B$1:$B$3000,SMALL(IF(('Timetarget Roster Export'!$D$2:$D$3000=$B$3)*(('Timetarget Roster Export'!$E$2:$E$3000)*1=F5),ROW('Timetarget Roster Export'!$E$2:$E$3000)),COUNTIF(F$5:F5,F5))),"""")"
ws.Range("C5").FormulaArray = "=IF(D5=""Vacant"","""",IF(D5="""","""",IFERROR(VLOOKUP(D5*1,Emp!$B$2:$E$350,4,FALSE),"""")))"
[COLOR=#ff0000] ws.Range("A5").Copy ws.Range("A6:A170")[/COLOR]
ws.Range("B5").Copy ws.Range("B6:B170")
ws.Range("C5").Copy ws.Range("C6:C170")
End With
Next ws
End Sub
The code worked when I entered the formula in one cell in each sheet. But it gave ma an error and the line in red above gets highlighted in yellow when I added the next bit trying to copy one cell in the range below for all sheets.
What is it that I am doing wrong?
Regards
Asad
Last edited: