弯沉盆修正

6 篇文章 0 订阅

作用:修正弯沉盆值,使其保持递减趋势。

Sub XiuZheng()'按公式修正
Application.ScreenUpdating = False

Dim RowsCount As Long '总行数
Dim n As Integer '点数
RowsCount = ActiveSheet.UsedRange.Rows.Count

For i = 2 To RowsCount
If Cells(i, "AI").Value = 1 Then
    n = WorksheetFunction.CountA(Range(Cells(i, "G"), Cells(i, "O")))
    If Cells(i, 6 + n).Value > Cells(i, 5 + n).Value Then '最后一个大于倒数第二个
        Cells(i, 6 + n).Value = Cells(i, 5 + n).Value - 0.1
        Cells(i, 6 + n).Interior.ColorIndex = 3
    End If
    
    For j = n - 1 To 3 Step -1 '倒数第二个到第三个
        If Cells(i, 6 + j).Value > Cells(i, 5 + j).Value Then '后面一个大于前面一个
            Cells(i, 6 + j).Value = Cells(i, 7 + j).Value + 0.1
            Cells(i, 6 + j).Interior.ColorIndex = 3
        End If
    Next j
    
    If Cells(i, 6 + 2).Value > Cells(i, 6 + 1).Value Then '第二个大于第一个
        Cells(i, 6 + 2).Value = Cells(i, 6 + 1).Value - 0.4
        Cells(i, 6 + 2).Interior.ColorIndex = 3
    End If
End If    
Next i
Application.ScreenUpdating = True
End Sub

Sub FuCha()'采用线性插值,复查
Application.ScreenUpdating = False

Dim RowsCount As Long '总行数
Dim n As Integer '点数
RowsCount = ActiveSheet.UsedRange.Rows.Count

For i = 2 To RowsCount
    If Cells(i, "AI").Value = 1 Then
        n = WorksheetFunction.CountA(Range(Cells(i, "G"), Cells(i, "O")))
        For j = 8 To n + 5
            If Cells(i, j).Value < Cells(i, j + 1).Value Then
                Cells(i, j).Value = (Cells(i, j - 1).Value + Cells(i, j + 1).Value) / 2
                Cells(i, j).Interior.ColorIndex = 6
            End If
        Next j
    End If
Next i
Application.ScreenUpdating = True
End Sub

Sub MakeTheSame()'使相邻的值相近的单元格内数值一样
Application.ScreenUpdating = False

Dim RowsCount As Long '总行数
Dim n As Integer '点数
Dim tmp As Double
RowsCount = ActiveSheet.UsedRange.Rows.Count

For i = 2 To RowsCount
    If Cells(i, "AI").Value = 1 Then
        n = WorksheetFunction.CountA(Range(Cells(i, "G"), Cells(i, "O")))
        For j = 8 To n + 5
            If Abs(Cells(i, j).Value - Cells(i, j + 1).Value) < 0.01 Then
                Cells(i, j).Value = Application.WorksheetFunction.Max(Cells(i, j).Value, Cells(i, j + 1).Value)
                Cells(i, j + 1).Value = Application.WorksheetFunction.Max(Cells(i, j).Value, Cells(i, j + 1).Value)
                Cells(i, j).Interior.ColorIndex = 6
            End If
        Next j
    End If
Next i
Application.ScreenUpdating = True
End Sub

存在的问题:上万行数据时,运行速度很慢。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值