Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 03-30-2019, 10:56 AM
p45cal's Avatar
p45cal p45cal is offline Need ca macro to remplace all line breaks inside all cells Windows 10 Need ca macro to remplace all line breaks inside all cells Office 2016
Expert
 
Join Date: Apr 2014
Posts: 947
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

Code:
Sub blah()
'Sheets("Before").Copy After:=Sheets(Sheets.Count)'only used to copy the sheet to preserve original
Set myRange = Intersect(Columns("B:J"), ActiveSheet.UsedRange)
Application.DisplayAlerts = False
For colm = myRange.Columns.Count To 1 Step -1
  If colm <> 2 Then
    myRange.Columns(colm + 1).EntireColumn.Insert
    'Let Excel decide what to do with with strings that look like numbers:
    myRange.Columns(colm).TextToColumns DataType:=xlDelimited, Other:=True, OtherChar:=Chr(10), FieldInfo:=Array(Array(1, 1), Array(2, 1))
    
    'or:
  
    'Treat the numbers as text and keep them as such (this will preserve any leading zeroes - you might do this if the numbers are account numbers or numbers you neveer need to do arithmetic on:
    'myRange.Columns(colm).TextToColumns DataType:=xlDelimited, Other:=True, OtherChar:=Chr(10), FieldInfo:=Array(Array(1, 2), Array(2, 2))
  End If
Next colm
Columns("B").Insert
myRange.Offset(, -2).Resize(, 1).TextToColumns , DataType:=xlDelimited, Other:=True, OtherChar:="T", FieldInfo:=Array(Array(1, 5), Array(2, 1))
Application.DisplayAlerts = True
Range("A1:S1").Value = Array("Date", "Time", "01 Fonds", "01 Fonds 2", "02 Mbres", "03 YUPR", "03 YUPR 2", "04 JLMY", "04 JLMY 2", "05 RuffY", "05 RuffY 2", "06 LeFY", "06 LeFY 2", "07 TatiaY", "07 TatiaY 2", "08 MediaY", "08 MediaY 2", "09 RTFY", "09 RTFY 2")
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with line breaks and paragraph breaks in bullet point document philiphunter7 Word 8 05-10-2020 11:51 PM
Need ca macro to remplace all line breaks inside all cells Paragraph line breaks muymalestado Word 3 09-25-2011 05:06 AM
Invoking a command line from inside Word bolpom Word 1 03-16-2011 03:03 AM
Need ca macro to remplace all line breaks inside all cells Line breaks at each line in Web text ahazelwood Word 5 01-06-2011 02:37 PM
Need ca macro to remplace all line breaks inside all cells Unwanted line breaks P. Alkuin Word 2 03-15-2010 09:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:06 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