I have the following code in VBA:
Sub creditformat()
Dim ws As Worksheet
Dim lastrow As Long
`
Set ws = ThisWorkbook.Worksheets("Table1")
lastrow = ws.Cells(ws.Rows.Count, "AC").End(xlUp).Row
For i = 1 To lastrow
**If ws.Cells(i, "AC").Value = "N.A" Then**
ws.Cells(i, "AC").Value = "Unrated"
End If
Next i
End Sub`
The line between two asterisks is the one causing issues. Does anyone know how to resolve this? I thought it should be a fairly simply script, but somehow it doesn't work. Any help would be appreciated, thanks!
I've also tried defining a range, like
Set rng = ws.Range("AC2:AC" & lastrow)
For Each cell In rng
If cell.Value = "N.A" Then
cell.Value = "Unrated"
End If
Next cell
But it doesn't work as well
If IsError(cell.Value) Thenbecause "N.A" is only the visibility of the error type.