Removing carriage returns from a address field

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
 
R

RDub

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top