Pasting last value in row before hitting #N/A

T

Tumbleweed

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

*****
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top