2012-12-14 496 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