问题
I have a set of values that look like this:
Time        DataSet1        DataSet2
00:10:00    15              27
00:20:00    #N/A            25
00:30:00    33              45
00:40:00    #N/A            #N/A
00:50:00    #N/A            25
01:00:00    #N/A            12
Now, I want to fill all #N/A values with the previous valid value in the table. For example: the value for DataSet1 at 00:40:00, 00:50:00 and 01:00:00 should be 33. How does one do that?
回答1:
Select the area you want to fix and run this macro:
Sub FixData()
    Dim r As Range
    For Each r In Selection
        If r.Text = "#N/A" Then
            r.Value = r.Offset(-1, 0).Value
        End If
    Next
End Sub
For example, before:

and after:

回答2:
This should work for you:
=IF(ISERROR(<yourformulahere>),A1,<yourformulahere>)
Autofill from A2 to your last row.
Will only work if yourformula is "autofillable". (:
https://support.google.com/docs/answer/3093349
回答3:
- Select A1 then tap F5 and when the GoTo dialog appears, click Special. 
- Check Formulas and uncheck everything but Errors. 
- Click OK.
- Type = then ↑ and finalize with Ctrl+Enter.
The errors should be converted to the value above.
回答4:
Just in case you prefer a macro-way:
Dim val As String
Dim col_to_check As Long, cnt As Long
col_to_check = 2 ' We check the 2nd column
cnt = 1 ' We'll use it to check rows below
For i = 1 To ActiveSheet.UsedRange.Rows.Count
 If IsError(Cells(i, col_to_check)) Then
   val = Cells(i - 1, col_to_check)
   Cells(i, col_to_check) = val
   While IsError(Cells(i + cnt, col_to_check))
     Cells(i + cnt, col_to_check) = val
     cnt = cnt + 1
   Wend
 End If
 i = i + cnt - 1
 cnt = 1
Next i
回答5:
We need to fill in "#N/A" cells with a formula =above cell address.   
- CTRL+F
- Type #N/A
- Click Find All
- Highlight all with mouse as picture below.
- Click on one space above menu - see oval (do not close Find and Replace window)
- Start typing =andpress Up key.
- Press CTRL+Enter
- Copy and paste all as text, to get rid of formulas.

来源:https://stackoverflow.com/questions/28879818/changing-n-a-values-in-excel-to-last-non-error-value-in-the-spreadsheet