Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 05-13-2018, 11:04 PM
macropod's Avatar
macropod macropod is offline Any macro to selectively get rid of soft returns? Windows 7 64bit Any macro to selectively get rid of soft returns? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I suspect you want to do something like:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long, j As Long, StrTmp As String
With Selection
  For i = 1 To .Cells.Count
    StrTmp = .Cells(i).Value
    For j = Len(StrTmp) - 1 To 1 Step -1
      If Mid(StrTmp, j, 1) = Chr(10) Then
        If (Mid(StrTmp, j - 1, 1) <> Chr(10)) And (Mid(StrTmp, j + 1, 1) <> Chr(10)) Then
          StrTmp = Left(StrTmp, j - 1) & " " & Right(StrTmp, Len(StrTmp) - j)
        ElseIf (Mid(StrTmp, j + 1, 1) = Chr(10)) And (Mid(StrTmp, j + 2, 1) = Chr(10)) Then
          StrTmp = Left(StrTmp, j - 1) & Right(StrTmp, Len(StrTmp) - j)
        End If
      End If
    Next
    .Cells(i).Value = StrTmp
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any macro to selectively get rid of soft returns? Macro To Delete Specific Carriage Returns NeviZero Word VBA 2 02-09-2018 02:16 PM
Any macro to selectively get rid of soft returns? Can't Get Centering right with soft return Nathan8752 Word 10 11-19-2015 07:06 AM
Any macro to selectively get rid of soft returns? how to selectively highlight text in word cnyoon2 Word 1 08-04-2015 08:16 AM
Need to Selectively Merge Records to Different Places in a Word Directory-type Document TotheMoonAlice Mail Merge 3 03-27-2015 08:11 AM
How can I tag and selectively extract text (multiple files)? PaulFitz Word VBA 12 10-31-2014 08:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft