1、在VBA中输入:Sub 位置重复性()End Sub
2、在VBA中先定义可能使用的变量.Dim i As IntegerCells(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) = 0Cells(2, 5) = 0Cells(2, 6) = 0Cells(6, 4) = 0
3、在VBA中先进行数据的求和,再求平均值.For j = 2 To 151 Step 5Cells(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、在VBA中求得lj的和,然后求得平均值.For j = 2 To 151 Step 5Cells(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 'ljCells(6, 4) = Cells(6, 4) + Cells(j + 4, 8) 'lj求和NextCells(6, 4) = Cells(6, 4) / 30 'lj平均
5、在VBA中求得位置重复性.For j = 2 To 151 Step 5Cells(6, 5) = ((Cells(j + 4, 8) - Cells(6, 4)) ^ 2 / 29) ^ 0.5 '过程值Cells(2, 7) = Cells(6, 4) + 3 * Cells(6, 5) '位置重复性Next