excel導入時,如果有換行符,則會導致讀取錯行等亂七八糟的錯誤。
可以用宏代碼的方式對換行進行替換
Sub ReplaceCRLF() Dim rg As Range Set rg = Sheet1.UsedRange Dim str As String Dim cell As Range For Each cell In rg str = Replace(cell.Value, Chr(10), "") cell.Value = str Next End Sub
alt + f11, 打開宏編輯界面,貼入代碼。在Sheet1中,選中需要替換的范圍,執行即可