1. 程式人生 > >excel 用VBA將所有單元格內容全部轉換為文字

excel 用VBA將所有單元格內容全部轉換為文字

Sub 將所有列全部轉換為文字()

'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
End Sub