excel - 使用 Applescript 从找到的单元格中复制 excel 列
问题描述
我希望能够从找到的单元格中复制一整列。
我已经能够创建一些代码来查找单元格。现在,我需要能够选择找到单元格的整个列,然后将其复制到 AA 列以启动我的宏。
“other_values”列将始终出现在报告中,但很少出现在同一个地方,这对我创建的宏来说是个问题。我想把它放在右边,但总是在同一个位置,以便能够启动我的宏,而无需像我迄今为止所做的那样在数据中间添加列
tell application "Microsoft Excel"
activate
set othervalues to "other_values"
set searchRange to range ("A1:Z1")
set foundColumn to find searchRange what othervalues with match case
set rowCount to count of rows
goto reference foundColumn
end tell
此代码正常工作并选择术语“other_values”,无论它在哪里,知道它始终在文件的第一行。现在它需要选择列并复制它
我意识到我必须完成最困难的部分,但作为 Excel 和 Applescript 的新手,我不知道如何选择整个列
谢谢!
解决方案
另一种不涉及任何选择的方法:
从使用的范围开始,然后获取“其他值”列。构建 Z 列的范围,然后将“other_values”列复制到那里。
tell application "Microsoft Excel"
tell worksheet 1 of workbook 1
set cour to columns of used range
set ic to columns of used range whose value of cell 1 is "other_values" -- gets target column
set fri to first row index of last cell of last item of cour -- gets bottom row number
set zsa to intersect range1 entire row of range ("A1:A" & fri as text) range2 range ("Z1:Z" & fri as text) -- assembles destination range
copy range ic destination zsa
end tell
end tell
推荐阅读
- rest - 如何在 Talend Api 测试人员的 Get 请求中传递参数列表
- c++ - 如何使用参数值(仅在运行时知道)调用函数(仅在运行时知道)?
- java - 如何在java中生成多级(行和列)数据透视表
- python - 在 fnproject 函数中包含自己的项目代码
- python - 将 YAML 配置作为变量读取到 Python 脚本
- c++ - C++ 我需要了解在哪里使用指针和双指针
- mysql - 在mysql中计算具有相同值的每一行的列中的重复值
- sql - 在 SQL Server 的存储过程中对变量执行多个值
- c++ - 在 C++ 中打印指向不同原始数据类型的指针的内存地址
- cmake - ExternalProject 错误:文件试图在源目录中创建目录