|
删除空格事宜
请问各位大师:本人想将"主生产排程"工作表A列的空格删除,现录制的代码意思是说:在A列右边插入一空列,设公式为=TRIM(A2),向下填充,改为"自动计算(因本人默认的是手动计算)。再粘贴为数值.然后,设A2=B2,向下填充到最后一个非空单元格,粘贴为数值。最后,删除B列!
Sub 消除空格()
Dim rng As Integer
rng = [a65536].End(xlUp).Row
Sheets("主生产排程").Select
Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("A:B").Select
Selection.NumberFormatLocal = "G/通用格式"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=TRIM(RC[-1])"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B" & rng)
Range("B:B").Select
Calculate
Columns("B:B").Select
'Range("B5").Activate
Application.Run "PERSONAL.XLSB!选择性粘贴"
Range("A2").Select
'Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=+RC[1]"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A" & rng)
Range("A:A").Select
Calculate
Selection.End(xlDown).Select
Columns("A:A").Select
'Range("A21145").Activate
Application.Run "PERSONAL.XLSB!选择性粘贴"
Columns("B:B").Select
'Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
End Sub |
|