Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1889|回复: 8

[已解决]求助2个自定义函数

[复制链接]
发表于 2017-6-7 15:26 | 显示全部楼层 |阅读模式
本帖最后由 mate33 于 2017-6-8 08:55 编辑

求助2个自定义函数
最佳答案
2017-6-7 16:10
  1. Function myF(reg1 As Range, reg2 As Range)   '从下往上,从右往左
  2.     If reg1.Cells.Count > 1 Then myF = "第一参数只能选择一个单元格": Exit Function
  3.     For k = reg2.Cells.Count To 1 Step -1
  4.         x = reg2.Cells(k)
  5.         For m = Len(x) To 1 Step -1
  6.             xstr = xstr & Mid(x, m, 1)
  7.         Next
  8.     Next
  9.     n = Val(reg1.Value)
  10.     p = (n + 1) Mod Len(xstr): If p = 0 Then p = Len(xstr)
  11.     myF = Mid(xstr, p, 1)
  12. End Function

  13. Function myFF(reg1 As Range, reg2 As Range)   '从上往下,从左往右
  14.     If reg1.Cells.Count > 1 Then myFF = "第一参数只能选择一个单元格": Exit Function
  15.     For k = 1 To reg2.Cells.Count
  16.         x = reg2.Cells(k)
  17.         For m = 1 To Len(x)
  18.             xstr = xstr & Mid(x, m, 1)
  19.         Next
  20.     Next
  21.     n = Val(reg1.Value)
  22.     p = (n + 1) Mod Len(xstr): If p = 0 Then p = Len(xstr)
  23.     myFF = Mid(xstr, p, 1)
  24. End Function
复制代码

2个自定函数.rar

12.98 KB, 下载次数: 15

发表于 2017-6-7 15:43 | 显示全部楼层

使用道具 举报

发表于 2017-6-7 15:46 | 显示全部楼层

使用道具 举报

发表于 2017-6-7 15:48 | 显示全部楼层
此帖仅作者可见

使用道具 举报

发表于 2017-6-7 15:59 | 显示全部楼层
此帖仅作者可见

使用道具 举报

发表于 2017-6-7 16:10 | 显示全部楼层    本楼为最佳答案   
此帖仅作者可见

使用道具 举报

 楼主| 发表于 2017-6-7 16:53 | 显示全部楼层
此帖仅作者可见

使用道具 举报

发表于 2017-6-7 16:54 | 显示全部楼层
此帖仅作者可见

使用道具 举报

发表于 2017-6-7 22:17 | 显示全部楼层
此帖仅作者可见

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-25 14:42 , Processed in 1.017359 second(s), 14 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表