【笔记】EXCEL(VBA)借助宏录制工资条
各位大佬大家好,直接来笔记:Dim i As Long
For i = 2 To Range("A1").CurrentRegion.Rows.Count - 1
'
' 制作工资条 宏
'
'
ActiveCell.Offset(2, 0).Rows("1:2").EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Offset(-2, 0).Rows("1:1").EntireRow.Select
Selection.Copy
ActiveCell.Offset(3, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 0).Range("A1:G1").Select
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.499984740745262
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.499984740745262
.Weight = xlThin
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
ActiveCell.Offset(1, 0).Range("A1").Select
Next
End Sub
请大佬们多指正!!!! 据说过多使用选择语句会减慢速度哦 技术贴,学习了 技术贴,看起来像录制宏的 学习了,谢谢!!! 最近在了解vba,似乎就会用with...end with。 小白,太多ActiveCell😏 无效的外部过程 Range("A1").CurrentRegion.Rows.Count
获得("数据统计表")中A1单元格向右及向下连续有数据单元格的总行数
其间不能有空行或数据在横向或纵向有间断 //
Private Sub Workbook_Open()
Application.ScreenUpdating = False '防止屏幕抖动,屏幕刷新禁止
If DateValue(Date) > DateValue(Sheets("主页").) Then
p = InputBox("您的使用期限已经到期,请输入口令继续使用", , "")
If p <> "rjs7374521" Then MsgBox "口令错误,请按确定退出!": ThisWorkbook.Close False
Sheets("主页"). = Date + 180
End If
Login.Show
Sheets("模板").Select
Application.ScreenUpdating = True '防止屏幕抖动,屏幕刷新禁止
End Sub
//
这是个登录窗口,想问下怎么修改能跳过它,或者自己注册有效口令
、、
页:
[1]