I run into an issue when there aren't any rows of data after row 4. For example, the code works if data exists in rows 4 and 5, but will not work if data is only in row 4. I receive a debug error on the code in blue. Any thoughts?
Sub JF()
Application.ScreenUpdating = False
Sheets("Risk Factor Report").Select
Range("B4").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(RC[9]=""true"",RC[13]=""true"",RC[17]=""true"",RC[21]=""true""),""Review: ""&IF(RC[9]=""true"",""Issuer ""&IF(OR(RC[13]=""true"",RC[17]=""true""),""/ "",),)&IF(RC[13]=""true"",""Sector ""&IF(RC[17]=""true"",""/ "",),)&IF(RC[17]=""true"",""Industry""&IF(RC[21]=""true"",""/ "",),)&IF(RC[21]=""true"",""Country"",),""-"")"
Range("B5").Select
Dim lastRow As Long
lastRow = Cells(Rows.Count, "C").End(xlUp).Row
With ActiveSheet
.Range("B4").AutoFill Destination:=.Range("B4:B" & lastRow)
End With
Application.ScreenUpdating = True
End Sub
Sub JF()
Application.ScreenUpdating = False
Sheets("Risk Factor Report").Select
Range("B4").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(RC[9]=""true"",RC[13]=""true"",RC[17]=""true"",RC[21]=""true""),""Review: ""&IF(RC[9]=""true"",""Issuer ""&IF(OR(RC[13]=""true"",RC[17]=""true""),""/ "",),)&IF(RC[13]=""true"",""Sector ""&IF(RC[17]=""true"",""/ "",),)&IF(RC[17]=""true"",""Industry""&IF(RC[21]=""true"",""/ "",),)&IF(RC[21]=""true"",""Country"",),""-"")"
Range("B5").Select
Dim lastRow As Long
lastRow = Cells(Rows.Count, "C").End(xlUp).Row
With ActiveSheet
.Range("B4").AutoFill Destination:=.Range("B4:B" & lastRow)
End With
Application.ScreenUpdating = True
End Sub