Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have an Excel 2007 app that writes data to SQL Server. Whenever I have an apostrophe in a word within a cell, I replace it with double quotes to prevent it from hosing my query. For some reason, in some cells the find and replace code doesn't work. I entered the word "that's" into each cell in a selected range to test the following code: Selection.Replace What:="'", Replacement:="''", LookAt:=xlPart, _ SearchOrder:=xlByRows Most instances of the apostrophe are replaced correctly, but some are unchanged. I modified the code to look for ascii characters with the same result: Selection.Replace What:=chr(39), Replacement:=chr(34), LookAt:=xlPart, _ SearchOrder:=xlByRows When I manually select the range and invoke the Find and Replace command through the Excel UI, all instances of the apostrophe get replaced. How can I force the code to replace the apostrophes? TIA, -Jon |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Choose format while Find & Replace not working | Excel Discussion (Misc queries) | |||
Find and Replace function not working | Excel Discussion (Misc queries) | |||
Find/Replace Unshown Apostrophe | Excel Programming | |||
My Find and Replace function in Excel is not working? | Excel Worksheet Functions | |||
FIND and REPLACE ' apostrophe | Excel Discussion (Misc queries) |