excel 用VBA将所有单元格内容全部转换为文本

Sub 将所有列全部转换为文本()
t=timer
'Cells(Rows.Count, 1).End(xlUp).Row 获取第一列最后一个非空单元格的行号
s = Cells(1, Columns.Count).End(xlToLeft).Column '获取第一行最后一个非空单元格的列号
For i = 1 To s
    Columns(i).Select
    Selection.TextToColumns Destination:=Cells(1, i), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 2), TrailingMinusNumbers:=True
Next i
MsgBox "一共用时:" & Format(Timer - t, "#0.0000") & " 秒", , "友情提示!!"  '//提示 End Sub

 

posted on 2018-12-06 11:53  这个名字不好用  阅读(3337)  评论(0编辑  收藏  举报

导航