excel - 创建一个可以在多个工作表上运行的 VBA 宏
问题描述
我正在尝试制作一个调用其他宏(如下面的宏)并将它们应用于指定工作表的宏。
我认为问题在于我之前制作的它调用的宏没有正确编码以应用于它不活跃的工作表。
这是我的代码:
Sub limits_Monitoring_bores()
Dim sht As Worksheet, lastRow As Long
Set sht = ActiveWorkbook.Worksheet
'Name columns appropriately
With ActiveWorkbook.Worksheets(1)
.Cells(1, 4).Value = "Min"
.Cells(1, 5).Value = "Max"
.Cells(1, 7).Value = "20th Percentile"
.Cells(1, 8).Value = "80th Percentile"
.Cells(1, 10).Value = "20th Percentile"
.Cells(1, 11).Value = "80th Percentile"
End With
lastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
sh.Range("D2:D" & lastRow).Value = "=6"
sh.Range("E2:E" & lastRow).Value = "=8.5"
sh.Range("G2:G" & lastRow).Value = "=PERCENTILE(F:F,0.2)"
sh.Range("H2:H" & lastRow).Value = "=PERCENTILE(F:F,0.8)"
sh.Range("J2:J" & lastRow).Value = "=PERCENTILE(I:I,0.2)"
sh.Range("K2:K" & lastRow).Value = "=PERCENTILE(I:I,0.8)"
解决方案
推荐阅读
- python - 在 Pandas 中将字符串转换为日期字段时出错
- android - 在后台线程上从 GLSurfaceView 获取像素
- javascript - HTML 视频未在生产中播放
- javascript - VS Code 中的红色波浪线
- typescript - NVDA 未宣布扩展状态
- kubernetes - 如何使用 ytt 将 sidecar 容器添加到现有的 Kubernetes Deployment?
- c# - 链接到 iTextSharp 中的外部文件
- laravel - Laravel Mix 正在跳过一些 CSS 文件并且没有输出所有内容
- php - 运行 XAMPP 服务器时未获取 PHP/HTML 图像
- python - Python Flask:HTML 未呈现