Question : Excel Macro--Remove hidden carriage returns/new line characters from a specific Cell

Hello guys!
     I need your help with this one ASAP. I wrote an Excel macro that pulls data from a bunch of files in one directory into one new file. The data I am pulling is from specific cells within the other workbooks. The data pull has been working just fine until now. Problem is if someone put a linefeed/carriage return in the cell it throws off my output file. The files I pull from are templates which have hidden carriage returns/linefeeds for formatting so I cannot remove all of them but its one cell I am having trouble with.

How can I remove any hidden carriage return/linefeeds from the single cell of text before I paste it into my new file?
Right now I grab the value from each sheet using

LegendText = Cells(49,1)

how do I remove any hidden carriage return/linefeeds from my LegendText value?
Any help you guys can give is appreciated.

I am awarding 500 for this one because I have tried for over a week to get around it and now I am short on time.

Answer : Excel Macro--Remove hidden carriage returns/new line characters from a specific Cell

Not sure what that char is, You can simply try this assuming either its chr(10) or chr(120)

LegendText = Replace(Cells(49, 1), Chr(10), "")

or

LegendText = Replace(Cells(49, 1), Chr(120), "")

Saurabh...

Random Solutions  
 
programming4us programming4us