|
如题,已做好加载宏函数HT(),此加载宏名为"回弹计算.xla",在加载宏里有一个工作表,加载宏函数用的数据在这个工作表中,宏函数已测试正确,就是在做成加载宏时出错,个人认为应该是引用数据不对,(arr1 = Sheets(1).[a4:z404])但这些代码都是依葫芦画瓢做的,不会改,所以请大神帮忙,谢谢!- Option Explicit
- Function HT(回弹值 As Double, 碳化深度 As Double, 角度 As String, 浇筑面 As String) As String
-
- Dim i%, j1%, j2%, j%, r%, m%, m1%, m2% ', 回弹值 As Double, 碳化深度 As Double, 角度 As String, 浇筑面 As String '定义变量
- Dim arr, arr1, arr2, arr3, arr4 '定义数组
- arr1 = Sheets(1).[a4:z404]
- arr2 = Array(0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6)
- arr3 = Array(90, 60, 45, 30, 0, -30, -45, -60, -90)
- arr4 = Array("侧面", "表面", "底面")
- For j1 = 0 To UBound(arr4)
- If 浇筑面 = arr4(j1) Then
- m1 = j1 + 24
- End If
- Next j1
- For j2 = 0 To UBound(arr3)
- If 角度 = arr3(j2) Then
- m2 = j2 + 15
- End If
- Next j2
- For j = 0 To UBound(arr2)
- If 碳化深度 = arr2(j) Then
- m = j + 2
- End If
- Next j
- For i = 1 To UBound(arr1)
- If 回弹值 = arr1(i, 1) Then
- r = i
- End If
- Next i
- If arr1(r, m) = "<10" Then
- HT = "<10"
- ElseIf arr1(r, m) = ">60" Then
- HT = ">60"
- Else
- HT = arr1(r, m) + arr1(r, m1) + arr1(r, m2)
- End If
- End Function
复制代码
回弹计算.rar
(32.13 KB, 下载次数: 9)
|
|