|
楼主 |
发表于 2024-10-17 12:56
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Function FQUYU(ByVal a As Range, ByVal b As Range, _
ByVal c As Range, ByVal d As Range, _
ByVal e As Range)
Dim x, y, i, j, arr, brr
If VBA.IsArray(a) Then
arr = a: x = UBound(arr, 1): y = UBound(arr, 2)
ReDim brr(1 To x, 1 To y)
For i = 1 To x
For j = 1 To y
If arr(i, j) = "" _
Or arr(i, j) * 1 < c _
Or arr(i, j) * 1 > d Then
brr(i, j) = ""
Else
If e = 0 Then
brr(i, j) = Int((arr(i, j) - c) * b / (d + 1 - c)) & (arr(i, j) Mod b)
ElseIf e = 1 Then
brr(i, j) = Int((arr(i, j) - c) * b / (d + 1 - c))
ElseIf e = 2 Then
brr(i, j) = arr(i, j) Mod b
Else
brr(i, j) = ""
End If
End If
Next
Next
FQUYU = brr
Else
If a = "" Or a * 1 < c Or a * 1 > d Then
crr = ""
Else
If e = 0 Then
crr = Int((a - c) * b / (d + 1 - c)) & (a Mod b)
ElseIf e = 1 Then
crr = Int((a - c) * b / (d + 1 - c))
ElseIf e = 2 Then
crr = a Mod b
Else
crr = ""
End If
End If
FQUYU = crr
End If
End Function
老师:上边的代码运算结果完全正确!只是在后三个参数设置忘了缺省情况下的默认值。
1.参数3可缺省,缺省情况下默认为0;
2.参数4可缺省,缺省情况下默认为9;
3.参数5可缺省,缺省情况下默认为0.
|
|