|
<COLGROUP>
<COL style="WIDTH: 63pt; mso-width-source: userset; mso-width-alt: 2688" width=84>
<COL style="WIDTH: 27pt; mso-width-source: userset; mso-width-alt: 1152" width=36>
<COL style="WIDTH: 63pt; mso-width-source: userset; mso-width-alt: 2688" width=84>
<COL style="WIDTH: 27pt; mso-width-source: userset; mso-width-alt: 1152" width=36>
<COL style="WIDTH: 63pt; mso-width-source: userset; mso-width-alt: 2688" width=84>
<COL style="WIDTH: 27pt; mso-width-source: userset; mso-width-alt: 1152" width=36>
<COL style="WIDTH: 63pt; mso-width-source: userset; mso-width-alt: 2688" width=84>
<COL style="WIDTH: 27pt; mso-width-source: userset; mso-width-alt: 1152" width=36>
项目
1
项目
2
项目
3
项目
4
姓名
a
姓名
b
姓名
c
姓名
d
基本工资
100
基本工资
200
基本工资
300
基本工资
400
加班补贴
50
加班补贴
60
加班补贴
70
加班补贴
80
如果是要实现上述效果的话,执行下列宏即可。注意:使用宏前要先选取数据区
Sub wlqInsCols()
'在使用区域内插入空白列并赋值给单元格
'晓月清风 2005-07-14
'ACCESS/OFFICE中国论坛 → Excel论坛 → Excel编程开发交流
'http://www.office-cn.net/vvb/post.asp?action=re&BoardID=90&replyID=146676&id=29694&star=1
Dim J As Integer, myselection As Range
If TypeName(Selection) <> "Range" Then Exit Sub
Application.ScreenUpdating = False
ActiveSheet.UsedRange.Columns.Select '选取已使用的列
Set myselection = Selection
For J = myselection.Columns.Count To 1 Step -1
myselection.Columns(J).EntireColumn.Insert
Cells(1, J) = "项目" '给空列的第一行赋值
Cells(2, J) = "姓名"
Cells(3, J) = "基本工资"
Cells(4, J) = "加班补贴"
Columns(J).Font.Bold = True
Next J
Application.ScreenUpdating = True
End Sub |
|