Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default removing special characters

I have a spreadsheet with 8 columns. One of the columns is text and contains
name's (both individuals and businesses), comments, and other miscellaneous
info.

A cost center has a macro that converts those 8 columns in each row into a
standard length string. After it creates the string for each row, it opens a
new workbook and writes each string on a separate row and finally saves the
"new" workbook as a csv file.

The "new" csv file is then sent to another department where it is uploaded
into their system. Yesterday, there was a problem with the upload since it
contained a special character. (I'm currently finding out which ones are not
allowed.)

We have macros that cycle through all of the characters in a column (field)
and removes double quotes (") for instance. We just remove them. We do not
replace them with a space or anything else.

I really don't want to write 32 loops to check each row (1 field only) for
every special character. If there are 500 rows of data, it would have to run
16,000 loops to check that column for special characters.

Is there a better or easier way to remove all special characters from a
specific column? Thanks for the help......

--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default removing special characters

Just recorded this, should get you going

Columns("C:C").Replace What:="""", Replacement:="",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False

hth
Keith

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default removing special characters

You could use Edit, Replace in Excel (for the VBA equivalent just use the
recorder).

You could also do it with code cell by cell by using Replace, eg:

Dim rng As Range
(code to select relevant ranges in sheet)
For Each rng In Selection
rng.Value = Replace(rng.Value,Chr(34),"") 'this replaces inverted
commas/quotes
Next

"JT" wrote:

I have a spreadsheet with 8 columns. One of the columns is text and contains
name's (both individuals and businesses), comments, and other miscellaneous
info.

A cost center has a macro that converts those 8 columns in each row into a
standard length string. After it creates the string for each row, it opens a
new workbook and writes each string on a separate row and finally saves the
"new" workbook as a csv file.

The "new" csv file is then sent to another department where it is uploaded
into their system. Yesterday, there was a problem with the upload since it
contained a special character. (I'm currently finding out which ones are not
allowed.)

We have macros that cycle through all of the characters in a column (field)
and removes double quotes (") for instance. We just remove them. We do not
replace them with a space or anything else.

I really don't want to write 32 loops to check each row (1 field only) for
every special character. If there are 500 rows of data, it would have to run
16,000 loops to check that column for special characters.

Is there a better or easier way to remove all special characters from a
specific column? Thanks for the help......

--
JT

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default removing special characters

On Wed, 12 Dec 2007 07:01:02 -0800, JT wrote:

I have a spreadsheet with 8 columns. One of the columns is text and contains
name's (both individuals and businesses), comments, and other miscellaneous
info.

A cost center has a macro that converts those 8 columns in each row into a
standard length string. After it creates the string for each row, it opens a
new workbook and writes each string on a separate row and finally saves the
"new" workbook as a csv file.

The "new" csv file is then sent to another department where it is uploaded
into their system. Yesterday, there was a problem with the upload since it
contained a special character. (I'm currently finding out which ones are not
allowed.)

We have macros that cycle through all of the characters in a column (field)
and removes double quotes (") for instance. We just remove them. We do not
replace them with a space or anything else.

I really don't want to write 32 loops to check each row (1 field only) for
every special character. If there are 500 rows of data, it would have to run
16,000 loops to check that column for special characters.

Is there a better or easier way to remove all special characters from a
specific column? Thanks for the help......


It'd be easier to design if we knew what the special characters are, or what
they are not.

You could loop through the column using regular expression and remove all the
special characters (or retain the non-special ones).

====================================
Sub foo()
Dim c As Range
Dim re As Object
Const sPat As String = "[!@#$%^&*()""]" 'list of special characters

Set re = CreateObject("vbscript.regexp")
re.Pattern = sPat
re.Global = True

For Each c In Selection
c.Value = re.Replace(c.Text, "")
Next c
End Sub
====================================

Or, for example, if it is simpler to list the allowable characters, and let us
say that the only allowable characters are letters and digits, you could change
sPat in above to "[^A-Za-z0-9]"




--ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default removing special characters

Hi. Could you share your macro with me? I'm trying to eliminate those pesky
"" myself.
Thanks,

"JT" wrote:

I have a spreadsheet with 8 columns. One of the columns is text and contains
name's (both individuals and businesses), comments, and other miscellaneous
info.

A cost center has a macro that converts those 8 columns in each row into a
standard length string. After it creates the string for each row, it opens a
new workbook and writes each string on a separate row and finally saves the
"new" workbook as a csv file.

The "new" csv file is then sent to another department where it is uploaded
into their system. Yesterday, there was a problem with the upload since it
contained a special character. (I'm currently finding out which ones are not
allowed.)

We have macros that cycle through all of the characters in a column (field)
and removes double quotes (") for instance. We just remove them. We do not
replace them with a space or anything else.

I really don't want to write 32 loops to check each row (1 field only) for
every special character. If there are 500 rows of data, it would have to run
16,000 loops to check that column for special characters.

Is there a better or easier way to remove all special characters from a
specific column? Thanks for the help......

--
JT



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default removing special characters

On Thu, 31 Jan 2008 15:14:01 -0800, Abbey Normal
wrote:

Hi. Could you share your macro with me? I'm trying to eliminate those pesky
"" myself.
Thanks,

"JT" wrote:

I have a spreadsheet with 8 columns. One of the columns is text and contains
name's (both individuals and businesses), comments, and other miscellaneous
info.

A cost center has a macro that converts those 8 columns in each row into a
standard length string. After it creates the string for each row, it opens a
new workbook and writes each string on a separate row and finally saves the
"new" workbook as a csv file.

The "new" csv file is then sent to another department where it is uploaded
into their system. Yesterday, there was a problem with the upload since it
contained a special character. (I'm currently finding out which ones are not
allowed.)

We have macros that cycle through all of the characters in a column (field)
and removes double quotes (") for instance. We just remove them. We do not
replace them with a space or anything else.

I really don't want to write 32 loops to check each row (1 field only) for
every special character. If there are 500 rows of data, it would have to run
16,000 loops to check that column for special characters.

Is there a better or easier way to remove all special characters from a
specific column? Thanks for the help......

--
JT


The "macro" was in this thread. Here's a copy of what I wrote befo

It'd be easier to design if we knew what the special characters are, or what
they are not.

You could loop through the column using regular expression and remove all the
special characters (or retain the non-special ones).

====================================
Sub foo()
Dim c As Range
Dim re As Object
Const sPat As String = "[!@#$%^&*()""]" 'list of special characters

Set re = CreateObject("vbscript.regexp")
re.Pattern = sPat
re.Global = True

For Each c In Selection
c.Value = re.Replace(c.Text, "")
Next c
End Sub
====================================

Or, for example, if it is simpler to list the allowable characters, and let us
say that the only allowable characters are letters and digits, you could change
sPat in above to "[^A-Za-z0-9]"


--ron
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
Removing Special characters in Excel Eddie Ortiz Excel Discussion (Misc queries) 9 April 3rd 23 03:43 PM
Removing Special Characters Cathy Landry Excel Worksheet Functions 2 March 23rd 10 07:27 PM
Special characters Gilles Desjardins Excel Worksheet Functions 2 December 8th 04 04:17 AM
Removing special characters and extra white space dougmcc1 Excel Programming 5 June 24th 04 01:27 AM
removing special characters Kevin Stecyk Excel Programming 1 October 23rd 03 05:21 PM


All times are GMT +1. The time now is 10:44 AM.

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"