Pasting last value in row before hitting #N/A

  • Thread starter Thread starter Julie
  • Start date Start date
Here's something to start with,
*****
Sub check_NA()

Dim iColumn As Integer
Dim bStatus As Boolean

' set iColumn for start of for-next loop at column B
iColumn = 2

For iColumn = 2 To 10
' check for #N/A IsError returns True if #N/A
bStatus = Application.WorksheetFunction.IsError(Cells(21, iColumn))
If bStatus Then
' Set A1 equal to the value of the cell one back from the first #N/A
Cells(11, 1).Value = Cells(21, iColumn - 1).Value
' When the #N/A is found stop the for-next by setting iColumn
greater than 10
iColumn = 11
End If

Next iColumn


End Sub

*****
 
Back
Top