you must replace the single apostrophe with two. For instance: if I had a variable (LastName) that held the value "O'Reily" and I used this variable in an insert statement, then it would throw an error. What you need to do is this:
LastName=replace(LastName,"'","''")