Removing carriage returns from a address field

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

Hi

I am exporting some information from fields in a form to create an excel
document
using code (part of code below). The phAddress field sometimes contains a
number of carriage returns. Is there a way to remove these in code so they do
not appear in the created spreadsheet.

Thanks

Matt

With xlSheet
.Cells(10, 1).Value = Me.phContactname
.Cells(27, 3).Value = Me.phAddress
.Cells(7, 3).Value = Me.phTown
End With
 
If you just want to remove the CarrageReturn's

.Cells(27, 3).Value = Replace(Me.phAddress ,vbcr,"")

If you want to replace the CarrageReturn's and the LineFeed's

.Cells(27, 3).Value = Replace(Replace(Me.phAddress ,vbcr,""),vblf,"")

This also might work for replacing CarrageReturn's and LineFeed's

.Cells(27, 3).Value = Replace(Me.phAddress ,vbcrlf,"")

Rdub
 
Back
Top