excel 中添加换行符:

  :alt+enter

去掉excel中的换行符有三种方法:

注:解决过程中翻阅其他博客,看到如下方式:

1、看到有的说全选后“取消自动换行”,保存后,再打开,依然存在换行符

2、ctrl+H,然后按住alt输入“10”或者“0010”,然后替换,测试无效,可能我操作不对

解决办法:

M1:

  1. 直接查找替换,选中你要替换的位置or全选(ctrl+a)
  2. 然后按 ctrl+h,打开替换界面
  3. 在替换内容窗口,输入ctrl+j,看起来是空的,但是你能看到一个点闪烁。
  4. 在替换为窗口,输入你要替换的内容,什么也不输入表示删掉
  5. 然后按照需要选择全部替换,或者替换

M2 and M3:不翻译了,看起来有点麻烦

原文链接:https://www.ablebits.com/office-addins-blog/2013/12/03/remove-carriage-returns-excel/

Delete line breaks using Excel formulas

Pros: you can use a formula chain / nested formulas for complex cell text processing. For example, it is possible to remove carriage returns and then eliminate excess leading and trailing spaces and those between words.

Or you may need to delete carriage returns to use your text as an argument of another function without changing the original cells. For example, if you want to be able to use the result as an argument of the function =lookup ().

Cons: you'll need to create a helper column and follow many extra steps.

  1. Add the helper column to the end of your data. You can name it "1 line".
  2. In the first cell of the helper column (C2), enter the formula to remove / replace line breaks. Here you can see several helpful formulas for different occasions:
    • Handle both Windows and UNIX carriage return/ line feeds combinations.
      =SUBSTITUTE(SUBSTITUTE(B2,CHAR(13),""),CHAR(10),"")
    • The next formula will help you replace line break with any other symbol (comma+space). In this case lines will not join and extra spaces will not appear. 
      =TRIM(SUBSTITUTE(SUBSTITUTE(B2,CHAR(13),""),CHAR(10),", ")
    • If you want to remove all nonprintable characters from text, including line breaks:
      =CLEAN(B2)

  3. Copy the formula across the other cells in the column.
  4. Optionally, you can replace the original column with the one where the line breaks were removed:
    • Select all cells in column C and press Ctrl + C to copy the data to clipboard.
    • Now pick the cell B2 and press the Shift + F10 shortcut. Then just press V.
    • Remove the helper column.

VBA macro to get rid of line breaks

Pros: Being created once, can be reused in any workbook.

Cons: you need to have the basic knowledge of VBA.

The VBA macro from the example below deletes carriage returns from all cells in the currently opened worksheet (active worksheet).

Sub RemoveCarriageReturns()
    Dim MyRange As Range
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
 
    For Each MyRange In ActiveSheet.UsedRange
        If 0 < InStr(MyRange, Chr(10)) Then
            MyRange = Replace(MyRange, Chr(10), "")
        End If
    Next
 
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
End Sub

If you don't know VBA really well, see How to insert and run VBA code in Excel

excel 添加换行符,去除换行符:的更多相关文章

  1. (转载)SQL去除回车符,换行符,空格和水平制表符

    http://www.cnblogs.com/insus/p/4815336.html MS SQL去除回车符,换行符,空格和水平制表符,参考下面语句,一般情况是SQL接受富文本或是textarea的 ...

  2. SQL去除回车符,换行符,空格和水平制表符

    MS SQL去除回车符,换行符,空格和水平制表符,参考下面语句,一般情况是SQL接受富文本或是textarea的内容.在数据库接收到这些数据之后,还是对其做一些处理. ),),),''),' ','' ...

  3. sqlite 去除换行符

    去除换行符操作: update t_config_list ;

  4. python使用platform模块获取系统环境并去除换行符

    近来在porting一个网站,企图拿到这个网站的数据来做分析.为了支持多系统环境的正常运行.需要知道当前系统环境的是什么OS? 1.python内置platform库.可以很方便得到当前系统环境时什么 ...

  5. php去除换行符的方法小结(PHP_EOL变量的使用)

    本来在unix世界换行就用/n来代替,但是windows为了体现他的不同,就用/r/n,更有意思的是在mac中用/r.因此unix系列用 /n,windows系列用 /r/n,mac用 /r,这样就用 ...

  6. SQL的查询结果复制到Excel 带标题Head 有换行符导致换行错乱 的解决方案

    将SQL查询到的结果保存为excel有很多方法,其中最简单的就是直接复制粘贴了 1.带Head的复制粘贴 1)先左击红色区域实现选择所有数据 2)随后右击选择Copy with Headers  再粘 ...

  7. MySQL去除表里数据回车符,换行符,空格和水平制表符

    MySQL去除表里数据回车符,换行符,空格和水平制表符 最近导数据的时候发现表里有好多回车符,换行符,水平制表符,MySQL的trim函数没办法去掉回车和换行,只能去掉多余的空格,可以用MySQL的r ...

  8. sqlserver数据库 去除字段中空格,换行符,回车符(使用replace语句)

    SQL中可以使用Replace函数来对某个字段里的某些字符进行替换操作,语法如下: 语法 REPLACE ( original-string, search-string, replace-strin ...

  9. sql中去掉换行符和回车符

    sql 中,char(13),char(10)或nchar(13),nchar(10)可表示SQL中的回车换行符,但是会以空格的形式显示.replace(replace(字段名,char(10), ' ...

  10. CCLabelTTF 如何支持换行符和换行

    参考自http://www.cocos2d-x.org/wiki/How_does_CCLabelTTF_support_line_breaks_and_wrapping 环境: cocos2d-x ...

随机推荐

  1. ajax请求格式

    ajax请求格式........... var rowsData = $('#receiptPrintList').datagrid('getSelections'); $.ajax({ type: ...

  2. LUA pcall 多个返回值

    You call lua_pcall with the number of arguments you are passing and the number of results you want. ...

  3. Debug 路漫漫-06

    FSBPR 迭代一轮就停止???…… 循环条件没有问题.. 达到收敛条件了?——参数变化小于1e-4…? deltaU =0 —— U没有更新?——incU < 0 —— 取消动量(前半部分即可 ...

  4. LATeX 插入脚注

    LATeX 插入脚注: 使用  \footnote{...注释内容} 命令: To maximize the lower-bound $ we employ conjugate gradient me ...

  5. POJ 3253 Fence Repair (哈夫曼树)

    Fence Repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 19660   Accepted: 6236 Des ...

  6. 【Oracle】Oracle中使用转义字符

    1.Oracle 特殊字符 转义 关键词:oracle    转义                                           环境:oracle9i plsql 在plsql ...

  7. javascript 中 split 函数分割字符串成数组

    分割字符串成数组的方法有很多,不过使用最多的还是split函数 <script language="javascript"> str="2,2,3,5,6,6 ...

  8. 【转】DRY原则的误区

    很多编程的人,喜欢鼓吹各种各样的“原则”,比如KISS原则,DRY原则…… 总有人把这些所谓原则奉为教条或者秘方,以为兢兢业业地遵循这些,空喊几个口号,就可以写出好的代码.同时,他们对违反这些原则的人 ...

  9. appium简明教程(11)——使用resource id定位(仅支持安卓4.3以上系统)

    上一节乙醇带大家了解了appium的定位策略.实际上appium的控件定位方式是完全遵守webdriver的mobile扩展协议的. 这一节将分享一下如何使用resource id来定位android ...

  10. Shell脚本:向磁盘中批量写入数据

    一.关于本文 工作要做的监控系统需要监控磁盘空间的使用率并报警.在测试这个功能的时候需要模拟两个场景:一是磁盘空间不断增长超过设定的阈值时,需要触发报警机制:二是磁盘空间降落到低于报警阈值的时候,不再 ...