I have a piece of VBA code that looks up value from another excel to create a True/False flag and based on the flag, I have set two different char values. I get 'object required' error in the following code. Can some one please explain why?
Sub test()
Dim part1 As String
Dim part2 As String
Dim a As Range
part1 = "=ifna(INDEX('DRG and Zip Summaries'!$A$10:$A$58,MATCH('DRG Summary Target'!F2 ""x_x_x"""
part2 = ",'DRG and Zip Summaries'!$C$10:$C$58,0)),'FALSE')"
With Range("A2:A183").FormulaArray = part1
.Replace """x_x_x""", part2
End With
For Each a In Range("A2:A183")
If a.Value = "FALSE" Then
Range("B" & a.rownum) = Chr(168)
Else: Range("B" & a.rownum) = Chr(254)
End If
Next
End Sub
Range("B" & a.rownum)is incorrect, it should beRange("B" & a.Row). Also, you should qualify your referecnes, for instanceWorkbooks("Workbook Name").Sheets("Sheet Name").Range("A2:A183").