Hi, hope someone can help me. I'm trying to write a VBA macro to remove alternate line breaks (alt+0010 or alt+enter) from a number of cells. The worksheet is output from a risk register and I need to tidy it up before presenting to senior managers. The cells look like this:
- text1(alt+0010)
(alt+0010)
- text2(alt+0010)
By removing the alternate line breaks I want to shift the text up to look like this:
- text1(alt+0010)
- text2(alt+0010)
I'm very new to writing VBA code, but I realise I can use the Substitute worksheetfunction and a for next loop, but it appears to do nothing. Can anyone give me any advice. The code I've written so far is:
Dim Result As String
Dim b As Long
With Selection
For b = 2 To 20 Step 2 (there aren't any more than 10 instances per cell)
Result = Application.WorksheetFunction.Substitute(ActiveCell, " & Chr(10) & ", "", b)
Next b
End With
Range("P3").Value = Result
I know it still needs some work to do the whole document, but one step at a time!
Any help gratefully received.
David
- text1(alt+0010)
(alt+0010)
- text2(alt+0010)
By removing the alternate line breaks I want to shift the text up to look like this:
- text1(alt+0010)
- text2(alt+0010)
I'm very new to writing VBA code, but I realise I can use the Substitute worksheetfunction and a for next loop, but it appears to do nothing. Can anyone give me any advice. The code I've written so far is:
Dim Result As String
Dim b As Long
With Selection
For b = 2 To 20 Step 2 (there aren't any more than 10 instances per cell)
Result = Application.WorksheetFunction.Substitute(ActiveCell, " & Chr(10) & ", "", b)
Next b
End With
Range("P3").Value = Result
I know it still needs some work to do the whole document, but one step at a time!
Any help gratefully received.
David