excel - 插入列和自动填充列标题的宏
问题描述
我想在表格之间插入两列,并从“I12”自动填充到“J12”。我设法通过记录宏来添加列,但我想自动填充列,直到“评论”列之前。我无法记录宏,因为插入的列数可能会有所不同。
8 ] 1
Sub column_insert()
'Range("Table1[[#Headers],[Inspection Tool (ID '#-Due Date)]:[Comment]]").Column.Insert
Dim headerColumn As Long
Dim headerColumn4 As Long
headerColumn = Cells.Find(What:="Comment").Column
'MsgBox (headerColumn)
For i = 1 To 2
Columns(headerColumn).Insert
Next i
Dim headerColumn2 As Long
headerColumn2 = Cells.Find(What:="Comment").Column - 1
'MsgBox (headerColumn2)
Dim LastColumn As Long
LastColumn = Cells(12, Columns.Count).End(xlToLeft).Column
Range("Table1[[#Headers],[Sample 1]:[Result ]]").Select
Selection.AutoFill Destination:=Range(Range("J12"), Cells(12, headerColumn2)), Type:=xlFillDefault
End Sub
有人可以帮助使用以前列中的公式自动填充新插入的列吗?
解决方案
推荐阅读
- javascript - 谓词可以是 JavaScript 中的对象吗?
- mysql - 将图像插入 MYSQL 表的 BLOB 字段
- angularjs - 如何在现有的 AngularJS 项目中使用 npm 包?
- javascript - 如何检测是否到达水平滚动条的末尾?
- java - 仅渲染 JTable 模型的一部分
- vue.js - v-html 和 v-text 有什么区别?
- c# - .Net Framework Entity Framework:如何避免内部选择?
- php - 如何使用 Jquery 和 PHP 更新选中文本
- javascript - 间隔比较不会在 JS 中爆炸
- java - 使用带有 WebClient 的反应器测试 MVC 控制器