• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

Macro not working on a 64 bit machine


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), " ")
End Sub

Open in new window

Thank you!
1 Solution
Harry LeeCommented:
I'm running Excel 2010 64bit on Windows 7 64bit, and I have no problem running the code.
Steven HarrisPresidentCommented:
What is the error message?
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

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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now