|
- '可以数组,可以单应用
- Function GetTwoNum(rgSource As Range, rgMin As Range, rgMax As Range) As Variant
- Dim arr As Variant, lngRow As Long, strTemp As String
- Dim lngInterval As Long, strResult As String
- Dim lngSource As Long, lngMin As Long, lngMax As Long
- If rgSource.Count = 1 Then
- ReDim arr(1 To 1, 1 To 1)
- arr(1, 1) = rgSource.Value
- Else
- arr = rgSource
- End If
- lngMin = rgMin.Value
- lngMax = rgMax.Value
-
- For lngRow = LBound(arr) To UBound(arr)
- strTemp = arr(lngRow, 1)
- If Trim(strTemp) = "" Then
- arr(lngRow, 1) = ""
- Else
- lngSource = Val(strTemp)
- lngInterval = (lngMax - lngMin + 1) \ 3
- strResult = (lngSource - lngMin) \ lngInterval
- strResult = strResult & (lngSource Mod 3)
- arr(lngRow, 1) = strResult
- End If
- Next
- GetTwoNum = arr
- End Function
复制代码 |
评分
-
2
查看全部评分
-
|