作者:zackcoolgirl_497 | 来源:互联网 | 2023-05-19 15:40
Hi All in new to using VBA in excel and was trying to create a function that would look at a number and return it as a six digit number.
嗨所有新的在excel中使用VBA并尝试创建一个函数,它将查看一个数字并将其作为六位数返回。
The function I wrote to try and accomplish this is below but when I use the command =Res(A1) in a cell I just get a #VALUE! as the answer.
我写的试图完成这个的功能如下,但是当我在单元格中使用命令= Res(A1)时,我得到一个#VALUE!作为答案。
The value in cell one at the moment is 30508.
目前单元格1中的值为30508。
Any help anyone could offer to resolve this would be greatly appreciated. Thanks Guys.
任何人都可以提供解决方案的任何帮助将不胜感激。多谢你们。
Function Res(myval As Integer) As Integer
Res = 0
If ((myval > 0) And (myval <10)) Then
Res = myval * 100000
ElseIf ((myval > 9) And (myval <100)) Then
Res = myval * 10000
ElseIf ((myval > 99) And (myval <1000)) Then
Res = myval * 1000
ElseIf ((myval > 999) And (myval <10000)) Then
Res = myval * 100
ElseIf ((myval > 9999) And (myval <100000)) Then
Res = myval * 10
ElseIf ((myval > 999999) And (myval <10000000)) Then
Res = myval / 10
Else
Res = myval
End If
End Function
3 个解决方案