A formula is used in cell G2. If the formula doesnt work, the cell has #N/A N/A
Is there a way to reference those cells in which I get an #N/A N/A?
A formula is used in cell G2. If the formula doesnt work, the cell has #N/A N/A
Is there a way to reference those cells in which I get an #N/A N/A?
try using
[VBA]
IsError()
[/VBA]
Not clear if you want VBA or Worksheet reference
=IF(ISNA(H8),"Error","")
[VBA]If Application.IsNA([H8]) Then MsgBox "Error"
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
[VBA]Sub PriceFormula()
Dim NumBlocks As Long
Dim Lastrow As Long
Dim i As Long
With ActiveSheet
Lastrow = .Cells(.Rows.Count, "F").End(xlUp).Row
For i = 3 To Lastrow
If .Cells(i, "G").Value = "IsError()" Then
.Cells(i, "G").Formula = _
"=BDH(RC[-5]&"" equity"",""px_last"")"
End If
Next i
End With
End Sub
[/VBA]
I am trying to say if the cells in column G have an error, then enter the formula above..
Try this
[VBA]
Sub PriceFormula()
Dim NumBlocks As Long
Dim Lastrow As Long
Dim i As Long
With ActiveSheet
Lastrow = .Cells(.Rows.Count, "F").End(xlUp).Row
For i = 3 To Lastrow
If Application.IsNA(.Cells(i, "G").Value) Then
.Cells(i, "G").Formula = _
"=BDH(RC[-5]&"" equity"",""px_last"")"
End If
Next i
End With
End Sub
[/VBA]