Excel:如何从单元格中删除所有回车符?

发布于 2024-09-26 06:14:43 字数 28 浏览 4 评论 0原文

我想去掉单元格中的所有回车符。我该怎么做?

I want to get rid of all the carriage returns in my cell. How do I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

满天都是小星星 2024-10-03 06:14:43

=CLEAN(A1)

Clean 从文本中删除所有不可打印的字符。 --Excel帮助文档

=CLEAN(A1)

Clean removes all nonprintable characters from text. -- Excel Help Documentation

太阳公公是暖光 2024-10-03 06:14:43

假设您的单元格位于 A1 中,您可以使用以下公式:

=SUBSTITUTE(A1,CHAR(10),"")

根据回车符,您可能必须使用 char(13) 而不是 char(10)

Assuming your cell is in A1, you can use the following formula:

=SUBSTITUTE(A1,CHAR(10),"")

Depending on the carriage return, you may have to use char(13) instead of char(10).

若水般的淡然安静女子 2024-10-03 06:14:43

选择一个或多个单元格,单击 Excel 菜单栏中的数据/文本到列,
在第一个对话框页面上选择“分隔”选项,单击“下一步”按钮,
取消选中除“其他”之外的所有内容,然后在旁边的字段中键入 Ctrl+J
(您不会在该框中看到任何内容,但列布局图表将显示
它在换行符处被分割(它们不是回车符)......
然后只需单击“完成”按钮。

Select the cell or cells, click Data/Text To Columns form Excel's menu bar,
choose the Delimited option on the first dialog page, click the Next button,
uncheck everything except Other and type Ctrl+J into the field next to it
(you won't see anything in that box, but the column layout chart will show
that it is being split at the line feeds (they are not carriage returns)...
then just click the Finish button.

野却迷人 2024-10-03 06:14:43

=Clean(A1)

此命令可以在 Excel 的“公式”选项卡 > > 下找到。文本。

=Clean(A1)

This command can be found in Excel under the formulas tab > text.

无所的.畏惧 2024-10-03 06:14:43
Sub RemoveLineBreaks()
    Application.ScreenUpdating = False
    Dim rngCel As Range
    Dim strOldVal As String
    Dim strNewVal As String

    For Each rngCel In Selection
        If rngCel.HasFormula = False Then
            strOldVal = rngCel.Value
            strNewVal = strOldVal
            Debug.Print rngCel.Address

            Do

            strNewVal = Replace(strNewVal, vbLf, " ")

            If strNewVal = strOldVal Then Exit Do
                strOldVal = strNewVal
            Loop

            If rngCel.Value <> strNewVal Then
                rngCel = strNewVal
            End If
        End If
        rngCel.Value = Application.Trim(rngCel.Value)
    Next rngCel
    Application.ScreenUpdating = True
End Sub
Sub RemoveLineBreaks()
    Application.ScreenUpdating = False
    Dim rngCel As Range
    Dim strOldVal As String
    Dim strNewVal As String

    For Each rngCel In Selection
        If rngCel.HasFormula = False Then
            strOldVal = rngCel.Value
            strNewVal = strOldVal
            Debug.Print rngCel.Address

            Do

            strNewVal = Replace(strNewVal, vbLf, " ")

            If strNewVal = strOldVal Then Exit Do
                strOldVal = strNewVal
            Loop

            If rngCel.Value <> strNewVal Then
                rngCel = strNewVal
            End If
        End If
        rngCel.Value = Application.Trim(rngCel.Value)
    Next rngCel
    Application.ScreenUpdating = True
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文