刚开始学习vba,请大神帮看看,在表中插入A列,添加序号,用遍历循环,太慢了。。。有好几千行。。怎样改????数组应该快,但不会写。。谢谢
可以手工插入,双击。。。搞,但我是再一个大表中要vba删除行,列后得出的。全部A股20260417是原表,要的效果是结果表,删除行列等等我都搞好了,原表代码列,要改数据格式。原表 ="688560" 要去掉=和" ",改为文本688560,我用替换搞好了。。。就是序号太慢了
Sub 删除列留AB()
Dim i As Long
Cells.Replace what:="*历史行情*", Replacement:="#NAME?", Lookat:=xlWhole
Cells.SpecialCells(xlCellTypeConstants, 16).EntireRow.Delete
Cells.Replace what:="*通达信*", Replacement:="#NAME?", Lookat:=xlWhole
Cells.SpecialCells(xlCellTypeConstants, 16).EntireRow.Delete
Range("C:E").Delete '保留涨幅AB,F列 Range("AE:AC").Delete
Columns("A:A").Select
'替换,=为空,"为 '
Selection.Replace what:="=", Replacement:=" ", Lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False, SearchFormat:=True, ReplaceFormat:=True
Selection.Replace what:=" " & """" & "", Replacement:="'", Lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False, SearchFormat:=True, ReplaceFormat:=True
Selection.Replace what:="" & """" & "", Replacement:="'", Lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False, SearchFormat:=True, ReplaceFormat:=True
Selection.Replace what:="'", Replacement:=" ", Lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False, SearchFormat:=True, ReplaceFormat:=True
'插入序号
Columns("A:A").Insert Shift:=xlToRight
Range("A1") = "序号"
n = Cells(Rows.Count, 2).End(3).Row
For i = 1 To n - 1
Cells(i + 1, "a") = i
Next
Range("D:D").SpecialCells(xlCellTypeBlanks) = 0 'DE列空的便是0
MsgBox "OK"
End Sub
附件.rar