ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
楼主: BrandSex

[讨论]有没有尝试过在自定义函数中改变其他单元格的值?

[复制链接]

TA的精华主题

TA的得分主题

发表于 2008-1-9 21:00 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

值没改过,但画线倒是完全没问题的,这个我验证过,而且天天在用!

TA的精华主题

TA的得分主题

发表于 2008-1-9 21:24 | 显示全部楼层
QUOTE:
以下是引用sunsoncheng在2008-1-9 21:00:05的发言:

值没改过,但画线倒是完全没问题的,这个我验证过,而且天天在用!

有没有实例?瞧瞧

不会是和LZ一样的大师吧

TA的精华主题

TA的得分主题

发表于 2008-1-9 21:40 | 显示全部楼层

Excel Function  一般不能更改单元格的值. (Change a cell value)

Only the calling cell or array and only by return value. 但还是可以实现更改单元格的值的.

Option Explicit
'*************************************************************************
'**╭⌒╮⌒╮          ︸ ︷  ﹀ ︿
'**╱◥██◣ Home      ﹀ ︷    ︸
'**|田|田 田|﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏
'**╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬
'**Mail:Stanley.pan2000@Hotmail.com
'*************************************************************************
Function ChangeCellValue(ByVal SelectCells As Range)
'Only the calling cell or array and only by return value
'Call changeCell
'SelectCells.Value = "testing"
'Application.Volatile
  On Error Resume Next
  ChangeCellValue = SelectCells.Interior.ColorIndex
  SelectCells.Value2 = "Only for testing"
End Function


Sub changeCell()
  Range("A1") = "testing"
End Sub



9FeTfvvx.zip (6.69 KB, 下载次数: 26)


[此贴子已经被作者于2008-1-9 21:41:25编辑过]

Gfa8adx8.zip

6.42 KB, 下载次数: 15

[讨论]有没有尝试过在自定义函数中改变其他单元格的值?

TA的精华主题

TA的得分主题

发表于 2008-1-10 07:57 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
QUOTE:
以下是引用stanleypan在2008-1-9 21:40:06的发言:

Excel Function  一般不能更改单元格的值. (Change a cell value)

Only the calling cell or array and only by return value. 但还是可以实现更改单元格的值的.




你这个实例并没有改变其它单元格的值啊?

仅仅是求参数的Interior.ColorIndex而已

TA的精华主题

TA的得分主题

发表于 2008-1-10 08:32 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2008-1-10 08:33 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2008-1-10 08:37 | 显示全部楼层
点一下fx 就可以看到单元格A1 值的变化.

TA的精华主题

TA的得分主题

发表于 2008-1-10 09:25 | 显示全部楼层
QUOTE:
以下是引用stanleypan在2008-1-10 8:37:43的发言:
点一下fx 就可以看到单元格A1 值的变化.

确实可以更改。不过这种方式和常规函数的操作方式大大不同。无法在工作中运用。

如果输入函数后单击回车就能改变参数所指定的单元格区域的值倒是有用。

TA的精华主题

TA的得分主题

 楼主| 发表于 2008-1-10 09:40 | 显示全部楼层
QUOTE:
以下是引用stanleypan在2008-1-10 8:37:43的发言:
点一下fx 就可以看到单元格A1 值的变化.

不错不错,我可以在使用A1之前调用Range("a1").Calculate

了解了一下UDF,果然有很多限制,看来很多东东还是要用UserForm来实现

Benefits of User Defined Excel Functions

  • Create a complex or custom math function.
  • Simplify formulas that would otherwise be extremely long "mega formulas".
  • Diagnostics such as checking cell formats.
  • Custom text manipulation.
  • Advanced array formulas and matrix functions.

Limitations of UDF's

  • Cannot "record" an Excel UDF like you can an Excel macro.
  • More limited than regular VBA macros. UDF's cannot alter the structure or format of a worksheet or cell.
  • If you call another function or macro from a UDF, the other macro is under the same limitations as the UDF.
  • Cannot place a value in a cell other than the cell (or range) containing the formula. In other words, UDF's are meant to be used as "formulas", not necessarily "macros".
  • Excel user defined functions in VBA are usually much slower than functions compiled in C++ or FORTRAN.
  • Often difficult to track errors.
  • If you create an add-in containing your UDF's, you may forget that you have used a custom function, making the file less sharable.
  • Adding user defined functions to your workbook will trigger the "macro" flag (a security issue: Tools > Macros > Security...).

TA的精华主题

TA的得分主题

发表于 2008-1-10 09:59 | 显示全部楼层

..


[此贴子已经被作者于2008-1-10 10:03:38编辑过]

[讨论]有没有尝试过在自定义函数中改变其他单元格的值?

[讨论]有没有尝试过在自定义函数中改变其他单元格的值?
r2x4HqVl.gif
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-5-21 00:08 , Processed in 0.033065 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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