Results 1 to 3 of 3

Thread: How to replace all paragraph marks in Microsoft Excel

  1. #1
    Join Date
    Oct 2011
    Posts
    89

    How to replace all paragraph marks in Microsoft Excel

    I am trying to replace "$$$" with a paragraph mark (ctrl + j) in an Excel chart. I keep getting the error message "formula too long". It seems I am searching for a formula. I need to search for a value. What am I doing wrong.

  2. #2
    Join Date
    Jul 2011
    Posts
    434

    Re: How to replace all paragraph marks in Microsoft Excel

    You can use a macro to do the change:
    Code:
    Option Explicit
    Sub testme01()
    Dim FoundCell As Range
    Dim ConstCells As Range
    Dim BeforeStr As String
    Dim AfterStr As String
    BeforeStr = "$$$"
    AfterStr = vblf
    With ActiveSheet
    Set ConstCells = Nothing
    On Error Resume Next
    Set ConstCells = .Cells.SpecialCells(xlCellTypeConstants, _
    xlTextValues)
    On Error GoTo 0
    If ConstCells Is Nothing Then
    MsgBox "Select some cells in the used range"
    Exit Sub
    End If
    With ConstCells
    'get as many as we can in one step
    .Replace what:=BeforeStr, Replacement:=AfterStr, _
    lookat:=xlPart, SearchOrder:=xlByRows
    Do
    Set FoundCell = .Cells.Find(what:=BeforeStr, _
    after:=.Cells(1), _
    LookIn:=xlValues, _
    lookat:=xlPart, _
    SearchOrder:=xlByRows, _
    searchdirection:=xlNext, _
    MatchCase:=False)
    If FoundCell Is Nothing Then
    'done, get out!
    Exit Do
    End If
    FoundCell.Value _
    = Replace(FoundCell.Value, BeforeStr, AfterStr)
    Loop
    End With
    End With
    End Sub
    If you're using xl97, change that Replace() to application.substitute(). If you're new to macros, you may want to read David McRitchie's intro. Ps. Try it against a copy of

    your data--just in case.

  3. #3
    Join Date
    Jul 2011
    Posts
    440

    Re: How to replace all paragraph marks in Microsoft Excel

    See the below link which will provide information on finding and replacing the items in Microsoft Excel.

    Find and replace text or other items

Similar Threads

  1. Replies: 2
    Last Post: 17-02-2012, 08:09 PM
  2. Replies: 2
    Last Post: 17-02-2012, 01:03 PM
  3. Replies: 2
    Last Post: 15-02-2012, 05:52 PM
  4. Replies: 2
    Last Post: 27-01-2012, 07:59 PM
  5. Replies: 1
    Last Post: 13-01-2012, 05:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,502,959.80429 seconds with 17 queries