Macro not working on a 64 bit machine

Hello,

I have the following code that works perfectly on any 32 bit excel. However when someone tries it on a 64 bit version, they get an error message.

Does anyone know how to overcome this so that the code works on both machines?

Sub ReplaceLineBreaksInCell()
    Dim cel As Range
    For Each cel In Selection
        cel = Replace(cel, Chr(10), " ")
    Next
End Sub

Open in new window


Thank you!
user2073Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Harry LeeCommented:
I'm running Excel 2010 64bit on Windows 7 64bit, and I have no problem running the code.
0
Steven HarrisPresidentCommented:
What is the error message?
0
byundtMechanical EngineerCommented:
Sometimes, VBA forgets which libraries the keywords belong to. It will issue an error message complaining about "Replace" for instance. One potential cause of confusion is another library that has a function by the same name--so the cure might be as simple as qualifying the code with the name of the library containing the function. For example:
cel.Value = VBA.Replace(cel.Value, Chr(10), " ")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
user2073Author Commented:
Very clever! that works. You were right too about the error message, I just had a look at the persons computer and that is exactly what was coming up.
Thank you for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.