2012-12-14 383 views
1

我在想如何能夠使用VBA並將HTML換行符(如\ r \ n)轉換爲Excel單元格中的換行符。Excel VBA將HTML換行符( r n)轉換爲Excel中的換行符

hello my name is pete \r\n\r\n here are a list of things I would like to do today: \r\n\r\n *wake up \r\n\r\n *eat breakfast 

我希望它在Excel中像這樣出現:比如,我有文字的下列字符串從HTML頁面複製

hello my name is pete 

here are a list of things I would like to do today: 

- wake up 
- eat breakfast 
+1

這就是字面上的「\ r \ n」,或者您的意思是表示CR + NL字符?你的單元格是否打開了「換行文字」? –

回答

2

我想你可能會尋找是字符串的直接文本替換。以下將爲當前活動的單元格執行此操作:

ActiveCell.Replace What:="\r\n", Replacement:=vbLf, LookAt:=xlPart, MatchCase:=False