|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
自定义函数:
F2单元格公式:=位号(A2)
G2单元格公式:=用量(F2)
加载宏的用法自己百度哈
- Function 位号(rng As Range, Optional str As String) As String
- Dim arr, brr()
- Dim i As Long, j As Long, n As Long
- Dim mystr As String, tstr As String
- Dim minVal As Integer, maxVal As Integer
-
- Application.Volatile
-
- If str = "" Then str = "-"
- arr = Split(rng, " ")
- For i = LBound(arr) To UBound(arr)
- If InStr(arr(i), str) Then
- For j = 1 To Len(arr(i))
- If Val(Mid(arr(i), j, 1)) <> 0 Then
- mystr = Left(arr(i), j - 1)
- Exit For
- End If
- Next j
- tstr = Replace(arr(i), mystr, "")
- minVal = Split(tstr, str)(0)
- maxVal = Split(tstr, str)(1)
- For j = minVal To maxVal
- n = n + 1
- ReDim Preserve brr(1 To n)
- brr(n) = mystr & CStr(j)
- Next j
- Else
- n = n + 1
- ReDim Preserve brr(1 To n)
- brr(n) = arr(i)
- End If
- Next i
-
- 位号 = Join(brr, " ")
- ' Application.Caller.Offset(0, 1).Value = UBound(brr)
-
- End Function
- Function 用量(rng As Range)
- Application.Volatile
- 用量 = UBound(Split(rng.Value, " ")) + 1
- End Function
复制代码
|
评分
-
3
查看全部评分
-
|