有朋友帮忙写了一段代码,但是会报错, n = rng.Columns(1).Find(What:="", LookIn:=xlFormulas, SearchDirection:=2, SearchFormat:=True).Row 这句话报错 object variable or with block variable not set Sub test() Dim t As Boolean, rng As Range Dim n%, i%, j%, k%, arr, brr Set rng = Sheets("results").UsedRange rng.Replace ".", "" Application.FindFormat.Interior.Color = rng(1, 1).Interior.Color n = rng.Columns(1).Find(What:="", LookIn:=xlFormulas, SearchDirection:=2, SearchFormat:=True).Row arr = rng.Rows("1:" & n + 1): brr = rng.Rows(n + 2 & ":" & rng.SpecialCells(11).Row) For i = 1 To UBound(arr) Step 2 For j = 1 To UBound(brr) For k = 1 To UBound(arr, 2) If arr(i, k) <> brr(j, k) Then t = False Exit For Else t = True End If Next If t Then rng.Rows(i + 1).FormulaR1C1 = "=r[-1]c" Next Next End Sub