|
- Private Sub CommandButton1_Click()
- Application.ScreenUpdating = False
- Dim m&, j&, p&, n$, s$, arr
- '(五)减余l
- m = Sheets("rK").[o1048576].End(xlUp).Row
- step2: For j = m - 59 To m - 15
- If Sheets("rK").Cells(j, "u") > 0 Then
- Exit For
- End If
- Next j
- ' If j = m + 1 Then GoTo step3
- If Application.CountIf(Sheets("rK").Range("u" & m - 59 & ":u" & m - 15), ">0") = 0 Then GoTo step3
- If Not IsError(Sheets("rK").Cells(j, "n").Value) Then
- If Sheets("rK").Cells(j, "n").Value = "b" Then
- If Sheets("rK").[m2] >= 2 Then
- Sheets("rK").Cells(m - 15, "o") = "=if(n" & m - 15 & "=""b"",b" & m - 15 & "-$U$" & j & "/( $m$2-1),b" & m - 15 & ")": n = "b"
- End If
- End If
- End If
- Sheets("rK").Cells(m - 15, "o").AutoFill Destination:=Sheets("rK").Range("o" & m - 59 & ":o" & m - 15 & ""), Type:=xlFillDefault
- For p = m - 59 To m - 15
- If Not IsError(Sheets("rK").Cells(p, "n").Value) Then
- If Sheets("rk").Cells(p, "n") = n Then
- s = s & "," & Sheets("rK").Cells(p, 1)
- End If
- End If
- Next p
- Sheets("rK").Cells(j, "o") = 0
- rqxs: arr = Split(Mid(s, 2), ",")
- If UBound(arr) <> -1 Then
- Sheets("rK").[q5].Resize(, UBound(arr) + 1) = arr
- End If
- MsgBox "完毕!"
- step3: Exit Sub
- End Sub
复制代码 没改,只把出错的地方加了点判断。 |
|