Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using VBA Replace function for single quote


Hi,

I want to replace single quote in my excel worksheet using replace
function.

The way I am using at the moment to replace blank spaces to empty
spaces in one entire column is

newSheet.Columns("A").Replace " ", "", xlPart

I would like to do the same with text containing single quote e.g
"""PNL """"W"""" TRANSFE
to
PNLWTRANSFE

What do you put in for the substring to search for?

thanks in advance

Galantis


--
galantis
------------------------------------------------------------------------
galantis's Profile: http://www.excelforum.com/member.php...o&userid=24739
View this thread: http://www.excelforum.com/showthread...hreadid=383053

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Using VBA Replace function for single quote

Hi Galantis,
try this:

Selection.Replace Chr$(34), "", xlPart

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Using VBA Replace function for single quote

Any time you need to put a quote mark into a literal string you simply double
it up, like this:

MyString = "I want to say ""Hello"" to you"

Therefore to search for a single quote mark in the Replace function you need
four quote marks like this:

NewString = Replace(OldString, """", "")

(Example is of the VB Replace function)

Why four quotes marks? The first is the opening quote mark for the literal
string value, the next two are the doubled-up quote mark within the literal
string, and the last is the closing quote mark to end the literal string.
Clear as mud?

"galantis" wrote:


Hi,

I want to replace single quote in my excel worksheet using replace
function.

The way I am using at the moment to replace blank spaces to empty
spaces in one entire column is

newSheet.Columns("A").Replace " ", "", xlPart

I would like to do the same with text containing single quote e.g
"""PNL """"W"""" TRANSFE
to
PNLWTRANSFE

What do you put in for the substring to search for?

thanks in advance

Galantis


--
galantis
------------------------------------------------------------------------
galantis's Profile: http://www.excelforum.com/member.php...o&userid=24739
View this thread: http://www.excelforum.com/showthread...hreadid=383053


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using VBA Replace function for single quote


thanks for the reply and it works!

now, how do you catch the error generated when find and replacing
substring that does not exist? a Null

I do not want a error pop-up message box which stops my marco.

galantis


--
galantis
------------------------------------------------------------------------
galantis's Profile: http://www.excelforum.com/member.php...o&userid=24739
View this thread: http://www.excelforum.com/showthread...hreadid=383053

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using VBA Replace function for single quote


it's okay, I found a similar item been asked from this forum and I will
try to use it.

thanks.

galantis.


--
galantis
------------------------------------------------------------------------
galantis's Profile: http://www.excelforum.com/member.php...o&userid=24739
View this thread: http://www.excelforum.com/showthread...hreadid=383053



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using VBA Replace function for single quote


thanks, suggestions works!

but now, how do I catch the error if the find and replace substring
don't find anything? returns a null?


I do not want a pop-up message box which stops my marco.

galantis


--
galantis
------------------------------------------------------------------------
galantis's Profile: http://www.excelforum.com/member.php...o&userid=24739
View this thread: http://www.excelforum.com/showthread...hreadid=383053

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Using VBA Replace function for single quote

I used to have a chart with all the keyboard alpha, numeric, and symbol
characters. I would like to know where to find the numeric value for this.
Chr$(34) I can't find the Chr$ anywhere.

"Roman" wrote:

Hi Galantis,
try this:

Selection.Replace Chr$(34), "", xlPart


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 301
Default Using VBA Replace function for single quote

The result can vary depending on the font used, but you can do the
following:
in A1, enter =CHAR(ROW()) and fill this down to A255.
Now, you can make the symbols larger, obviously, by increasing the font of
the column, to, say, 14 pt. - The first 32 rows or so will mainly just show
a little square, but scroll down.
Now, you can copy column A out to Columns B & beyond, and format each column
as a new font to see different symbols, especially Wingdings, etc.

You can use this chart to know how to enter the symbol directly. For
example, to enter a ¢ sign, you can see it's on row 162, so you can hold the
Alt key, and type 0162 from the numeric keypad (leading 0 important), then
let go of the Alt key and the symbol will appear.

Bob Umlas
Excel MVP

"lschuh" wrote in message
...
I used to have a chart with all the keyboard alpha, numeric, and symbol
characters. I would like to know where to find the numeric value for
this.
Chr$(34) I can't find the Chr$ anywhere.

"Roman" wrote:

Hi Galantis,
try this:

Selection.Replace Chr$(34), "", xlPart




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Using VBA Replace function for single quote

thank you. that's pretty neat.

"Bob Umlas" wrote:

The result can vary depending on the font used, but you can do the
following:
in A1, enter =CHAR(ROW()) and fill this down to A255.
Now, you can make the symbols larger, obviously, by increasing the font of
the column, to, say, 14 pt. - The first 32 rows or so will mainly just show
a little square, but scroll down.
Now, you can copy column A out to Columns B & beyond, and format each column
as a new font to see different symbols, especially Wingdings, etc.

You can use this chart to know how to enter the symbol directly. For
example, to enter a ¢ sign, you can see it's on row 162, so you can hold the
Alt key, and type 0162 from the numeric keypad (leading 0 important), then
let go of the Alt key and the symbol will appear.

Bob Umlas
Excel MVP

"lschuh" wrote in message
...
I used to have a chart with all the keyboard alpha, numeric, and symbol
characters. I would like to know where to find the numeric value for
this.
Chr$(34) I can't find the Chr$ anywhere.

"Roman" wrote:

Hi Galantis,
try this:

Selection.Replace Chr$(34), "", xlPart





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can the SUBSTITUTE function replace a double quote? Florence Excel Worksheet Functions 6 April 3rd 23 02:26 PM
vlookup and using single quote Bishop Excel Worksheet Functions 2 April 3rd 09 06:02 PM
using a single quote ' in SEARCH function ExTexan Excel Worksheet Functions 2 December 30th 06 01:11 PM
Removing leading single quote (') from cells with Search/Replace Arun Excel Discussion (Misc queries) 3 January 22nd 06 03:40 AM
Single quote in a where clause Poh[_2_] Excel Programming 0 July 9th 04 02:54 AM


All times are GMT +1. The time now is 11:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"