|
本帖最后由 mate33 于 2017-6-8 08:55 编辑
求助2个自定义函数
- Function myF(reg1 As Range, reg2 As Range) '从下往上,从右往左
- If reg1.Cells.Count > 1 Then myF = "第一参数只能选择一个单元格": Exit Function
- For k = reg2.Cells.Count To 1 Step -1
- x = reg2.Cells(k)
- For m = Len(x) To 1 Step -1
- xstr = xstr & Mid(x, m, 1)
- Next
- Next
- n = Val(reg1.Value)
- p = (n + 1) Mod Len(xstr): If p = 0 Then p = Len(xstr)
- myF = Mid(xstr, p, 1)
- End Function
- Function myFF(reg1 As Range, reg2 As Range) '从上往下,从左往右
- If reg1.Cells.Count > 1 Then myFF = "第一参数只能选择一个单元格": Exit Function
- For k = 1 To reg2.Cells.Count
- x = reg2.Cells(k)
- For m = 1 To Len(x)
- xstr = xstr & Mid(x, m, 1)
- Next
- Next
- n = Val(reg1.Value)
- p = (n + 1) Mod Len(xstr): If p = 0 Then p = Len(xstr)
- myFF = Mid(xstr, p, 1)
- End Function
复制代码
|
|