手把手教学.

工具/原料

  • 电脑
  • Excel

方法/步骤

  1. 1

    在VBA中输入:

    Sub 位置重复性()

    End Sub

  2. 2

    在VBA中先定义可能使用的变量.

    Dim i As Integer

    Cells(1, 1).Value = "X轴坐标"

    Cells(1, 2).Value = "Y轴坐标"

    Cells(1, 3).Value = "Z轴坐标"

    Cells(1, 4).Value = "X轴坐标平均值"

    Cells(1, 5).Value = "Y轴坐标平均值"

    Cells(1, 6).Value = "Z轴坐标平均值"

    Cells(1, 7).Value = "位置重复性"

    Cells(1, 8).Value = "方根值"

    Cells(5, 4).Value = "方根值取平均"

    Cells(5, 5).Value = "过程值"

    Cells(2, 4) = 0

    Cells(2, 5) = 0

    Cells(2, 6) = 0

    Cells(6, 4) = 0

  3. 3

    在VBA中先进行数据的求和,再求平均值.

    For j = 2 To 151 Step 5

    Cells(2, 4) = Cells(j + 4, 1) + Cells(2, 4) 'X轴求和

    Cells(2, 5) = Cells(j + 4, 2) + Cells(2, 5) 'Y轴求和

    Cells(2, 6) = Cells(j + 4, 3) + Cells(2, 6) 'Z轴求和

    Cells(j + 4, 1).Interior.Color = RGB(0, 255, 0)

    Cells(j + 4, 2).Interior.Color = RGB(0, 255, 0)

    Cells(j + 4, 3).Interior.Color = RGB(0, 255, 0)

    Next

    '------------------------------------------------

    Cells(2, 4) = Cells(2, 4) / (j - 122) 'X轴平均值

    Cells(2, 5) = Cells(2, 5) / (j - 122) 'Y轴平均值

    Cells(2, 6) = Cells(2, 6) / (j - 122) 'Z轴平均值

  4. 4

    在VBA中求得lj的和,然后求得平均值.

    For j = 2 To 151 Step 5

    Cells(j + 4, 8) = ((Cells(j + 4, 1) - Cells(2, 4)) ^ 2 + (Cells(j + 4, 2) - Cells(2, 5)) ^ 2 + (Cells(j + 4, 3) - Cells(2, 6)) ^ 2) ^ 0.5 'lj

    Cells(6, 4) = Cells(6, 4) + Cells(j + 4, 8) 'lj求和

    Next

    Cells(6, 4) = Cells(6, 4) / 30 'lj平均

  5. 5

    在VBA中求得位置重复性.

    For j = 2 To 151 Step 5

    Cells(6, 5) = ((Cells(j + 4, 8) - Cells(6, 4)) ^ 2 / 29) ^ 0.5 '过程值

    Cells(2, 7) = Cells(6, 4) + 3 * Cells(6, 5) '位置重复性

    Next

    END
经验内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。