vba - VBA - 在不同的列中添加不同的公式
问题描述
我有一张桌子,并成功创建了一个 vba 代码,它添加了一个 Vlookup 公式并向下拖动列。
Dim lastRow As Long
lastRow = Cells(Rows.Count, 8).End(xlUp).Row
Range("H5:H" & lastRow).Formula = "=VLOOKUP(A5,'XXX!$AA$5:$AM$2000,8,0)"
Range("H5:H" & lastRow).Value = Range("H5:H" & lastRow).Value
我现在遇到的问题是我想用所有不同的公式对大约 5 个其他列做同样的事情......我试图复制上面的代码,但更改了列和公式,但不断收到错误或不正确的结果。
IE
Dim lastRow As Long
lastRow = Cells(Rows.Count, 8).End(xlUp).Row
Range("H5:H" & lastRow).Formula = "=VLOOKUP(A5,'XXX!$AA$5:$AM$2000,8,0)"
Range("H5:H" & lastRow).Value = Range("H5:H" & lastRow).Value
lastRow = Cells(Rows.Count, 9).End(xlUp).Row
Range("G5:G" & lastRow).Formula = "=VLOOKUP(A5,'XXX!$AA$5:$AM$2000,9,0)"
Range("G5:G" & lastRow).Value = Range("G5:G" & lastRow).Value
任何帮助都感激不尽
谢谢
解决方案
推荐阅读
- node.js - 我应该打开服务器的 3000 端口来为 NodeJS 应用程序提供服务吗?
- angular - 如何在角度中为不同的模板设置单独的样式和脚本标签
- node.js - Stripe 客户出口不包含帐单地址
- python - 如何将此脚本转换为实际实现鼠标输入以移动到某些坐标
- c++ - 使用 openmp 没有加快 emplace_back 循环中的向量
- angular - 无法从使用 Cucumber 框架实现的 Typescript 中的功能文件中调用值
- google-apps-script - 在插入行时触发 onEdit()
- c# - 如何将对象移动到 linerenderer 行位置?
- python - 你如何过滤非空值弹性搜索?
- c++ - C++ 两阶段初始化