博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
excel 添加换行符,去除换行符:
阅读量:6587 次
发布时间:2019-06-24

本文共 2547 字,大约阅读时间需要 8 分钟。

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:不翻译了,看起来有点麻烦

原文链接:

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)

    Excel formula to delete carriage returns from cells

  3. .
  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 

 

转载于:https://www.cnblogs.com/lovychen/p/8875825.html

你可能感兴趣的文章
echarts添加点击事件
查看>>
html实现“加入收藏”代码
查看>>
机器学习之最优化问题
查看>>
Selenium 详解xpath定位
查看>>
网页做复制功能
查看>>
PHP中如何对二维数组按某个键值进行排序
查看>>
SharePoint 2013 EventHanlder工具
查看>>
jQuery和javascript的区别
查看>>
doctest --- 一个改善python代码质量的工具
查看>>
hdu1290
查看>>
hdu2141Can you find it?
查看>>
值类型和引用类型 (转)
查看>>
Axure RP 8 下载 激活可以使用的授权码、用户名、秘钥等
查看>>
20155303 2016-2017-2 《Java程序设计》第四周学习总结
查看>>
c语言基础课第三次作业
查看>>
MogileFS系统简单配置实例
查看>>
【转】[C# 基础知识系列]专题九 :深入理解泛型可变性
查看>>
AS3.0 学习笔记002
查看>>
map, hash_map, multimap的使用及区别
查看>>
NLog配置文件根节点
查看>>