Excel 各种代码(表内vb宏,非vb6)
**' 删除
'
Columns("A:D").Select
Selection.Clear
Columns("A:B").Select
Selection.Delete Shift:=xlShiftToLeft
'换列
Columns("F:G").Select
Range("G1").Activate
Selection.Cut
Columns("E:E").Select
Columns("F:G").Cut
ActiveSheet.Select Replace:=False
Columns("E:F").Select
Selection.Insert Shift:=xlShiftToRight
ActiveSheet.Select Replace:=False
ActiveSheet.Select Replace:=False
' 行高
'
Rows("1:2").Select
Selection.RowHeight = 26
' 列宽
Selection.ColumnWidth = 5.38
Columns("B:B").Select
Selection.ColumnWidth = 16.13
Columns("C:C").Select
'剧中
Columns("A:H").Select
Range("A3").Activate
Selection.VerticalAlignment = xlVAlignCenter
'4行以下高
Range("W3").Select
Selection.Formula = "=COUNTA(E:E)"
y = Range("W3").Value
P = 4
For x = 1 To y - 1
Rows(P & ":" & P).Select
Selection.RowHeight = 53
P = P + 1
Next
'新增3行合并列
o = 5
For x = 1 To y - 1
Rows(o & ":" & o).Select
With Rows(o & ":" & o + 2)
.Insert Shift:=xlShiftDown
.Select
End With
o = o + 4
Next
i = 4
For x = 1 To y - 1
Range("A" & i & " :" & "A" & i + 3).Select
With Selection
.Merge Across:=False
.HorizontalAlignment = xlHAlignCenter
End With
Range("B" & i & " :" & "B" & i + 3).Select
With Selection
.Merge Across:=False
.HorizontalAlignment = xlHAlignCenter
End With
Range("C" & i & " :" & "C" & i + 3).Select
With Selection
.Merge Across:=False
.HorizontalAlignment = xlHAlignCenter
End With
Range("D" & i & " :" & "D" & i + 3).Select
With Selection
.Merge Across:=False
.HorizontalAlignment = xlHAlignCenter
End With
Range("E" & i & " :" & "E" & i + 3).Select
With Selection
.Merge Across:=False
.HorizontalAlignment = xlHAlignCenter
End With
Range("F" & i & " :" & "F" & i + 3).Select
With Selection
.Merge Across:=False
.HorizontalAlignment = xlHAlignCenter
End With
Range("G" & i & " :" & "G" & i + 3).Select
With Selection
.Merge Across:=False
.HorizontalAlignment = xlHAlignCenter
End With
Range("H" & i & " :" & "H" & i + 3).Select
With Selection
.Merge Across:=False
.HorizontalAlignment = xlHAlignCenter
End With
i = i + 4
Next
'处理图片
'
ActiveSheet.Shapes.Range(Array("Picture 1")).Select
ActiveSheet.Shapes.SelectAll
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 170.0787401575
Selection.ShapeRange.Width = 85.0393700787
Selection.Placement = xlMoveAndSize
Application.CommandBars("Format Object").Visible = False
'
' 分列 宏
'
e = Application.ActiveWorkbook.Name
Windows(e).Activate
Columns("I:I").Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "x"
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), TrailingMinusNumbers:=True
'
' 删除多余
'
Sheets("x").Select
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
序号()
'
r = Range("C65536").End(xlUp).Row
lo = "A4:A" & r + 3
Range("A4:A7").Select
ActiveCell.FormulaR1C1 = "1"
Range("A8:A11").Select
ActiveCell.FormulaR1C1 = "2"
Range("A4:A11").Select
Selection.AutoFill Destination:=Range(lo)
运行其他宏
Application.Run "'表名字'!宏名字"
Application.Run "'1.xls'!宏1"**