明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3785|回复: 8

Lisp实现在EXCEL中自动填充

[复制链接]
发表于 2012-3-20 22:45:32 | 显示全部楼层 |阅读模式
本帖最后由 zdqwy19 于 2012-3-21 09:02 编辑

          用Lisp如何编写在excel选择一行某几个单元格的数据形式实现下拉填充的效果。
          I don't know the reason why you use"AutoFill"method or what the series you want to fill. You must give the default series defined by yourself if you want to use"AutoFill"method. I would like to suggest you to read the help topic about"AutoFill"method. I copied it and pasted it below. Please read it.
Excel Developer Reference
Range.AutoFill Method
Performs an autofill on the cells in the specified range.
Syntax
expression.AutoFill(Destination, Type)
expression  A variable that represents a Range object.
Parameters
Name Required/Optional Data Type Description
Destination Required Range The cells to be filled. The destination must include the source range.
Type Optional XlAutoFillType Specifies the fill type.
Return Value
Variant
Example

This example performs an autofill on cells A1:A20 on Sheet1, based on the source range A1:A2 on Sheet1. Before running this example, type 1 in cell A1 and type 2 in cell A2.
Visual Basic for Applications
Set sourceRange = Worksheets("Sheet1").Range("A1:A2")
Set fillRange = Worksheets("Sheet1").Range("A1:A20")
sourceRange.AutoFill Destination:=fillRange
        这是vba的自动填充说明,我用vlisp改了不成功,有哪位高手愿意帮忙修改一下用vlisp怎么写,谢谢!
"觉得好,就打赏"
还没有人打赏,支持一下

本帖被以下淘专辑推荐:

  • · excel|主题: 80, 订阅: 3
发表于 2012-3-21 10:28:54 | 显示全部楼层
本帖最后由 snddd2000 于 2012-3-21 10:31 编辑
  1. (vl-load-com)
  2. (setq excelapp0 (vlax-get-object "Excel.Application"))
  3. ;;excel程序对象,Application 对象
  4. (setq activeworkbook0 (vlax-get-property excelapp0 'ActiveWorkbook))
  5. ;;excel工作簿对象
  6. (setq activesheet0 (vlax-get-property activeworkbook0 'ActiveSheet))
  7. ;;excel工作表对象
  8. (setq cells0 (vlax-get-property activesheet0 'cells))
  9. ;;excel单元格对象
  10. (setq SourceRange (vlax-get-property cells0 'range "A1:A2"))
  11. (setq FillRange (vlax-get-property cells0 'range "A1:A20"))
  12. (vlax-invoke-method SourceRange 'autofill FillRange 2);;;2007版excel
 楼主| 发表于 2012-3-21 11:37:33 | 显示全部楼层
snddd2000 发表于 2012-3-21 10:28

       谢谢!看样子方法是正确的,不出现恼人的错误提示,就是我的电脑cpu一下子就跑了100.或许是我引用时错了,我在查查。
 楼主| 发表于 2012-3-21 12:45:44 | 显示全部楼层
解决了,是电脑测试时错误累加的结果,再次表示感谢。
发表于 2012-4-16 16:15:38 | 显示全部楼层
学习,看高手的成果
发表于 2013-8-15 07:20:56 | 显示全部楼层
谢谢沙发的源码
发表于 2015-6-6 10:30:00 | 显示全部楼层
谢谢沙发的源码!
发表于 2015-6-13 12:35:52 | 显示全部楼层
终于看到获得活动工作簿的代码了:(setq activeworkbook0 (vlax-get-property excelapp0 'ActiveWorkbook))。原来如此。谢谢。
发表于 2016-7-23 10:59:36 | 显示全部楼层
值得学习学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-20 06:20 , Processed in 0.180280 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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