Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Comma replacement

I am in Europe. I use by default coma as decimal separator.
In a particular situation I need to replace the coma by point. I have this
code:
Columns("p:p").Select
Selection.NumberFormat = "General"
Selection.Replace What:=",", Replacement:="."
But nothing is happening. Column P still has comma as decimal separator.

What am I doing wrong?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Comma replacement

on the sheet that you are working on, select the column , or range of cells,
set the format to general. then go to 'Edit', 'Replace', put a ',' in the
Find What and a '.' in the Replace With and then hit 'Replace All'.
I think that should work.

"Raul Sousa" wrote:

I am in Europe. I use by default coma as decimal separator.
In a particular situation I need to replace the coma by point. I have this
code:
Columns("p:p").Select
Selection.NumberFormat = "General"
Selection.Replace What:=",", Replacement:="."
But nothing is happening. Column P still has comma as decimal separator.

What am I doing wrong?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Comma replacement

On May 19, 2:40 pm, Raul Sousa
wrote:
I am in Europe. I use by default coma as decimal separator.
In a particular situation I need to replace the coma by point. I have this
code:
Columns("p:p").Select
Selection.NumberFormat = "General"
Selection.Replace What:=",", Replacement:="."
But nothing is happening. Column P still has comma as decimal separator.

What am I doing wrong?


I think this is failing because the comma is not actually part of the
contents of the cell, unless it is formatted as Text. In all number
formats the comma is 'virtual' - for display purposes only. In such
case, you will either need to build a Custom format that replaces the
comma with a dot or the cells will need to be formatted as text and
actual periods inserted were desired (probably not the way you want to
go).

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Comma replacement

Unfortunately it does not work.
If do this operation by code, it does not work, Even if I format that column
as text.

But,
If I do it manually, this is, select the column, and set the format to
general. Then go to 'Edit', 'Replace', put a ',' in the Find what and a '.'
in the Replace With and then hit 'Replace All'.
It works

I think it should also work with this code.


"T Lavedas" wrote:

On May 19, 2:40 pm, Raul Sousa
wrote:
I am in Europe. I use by default coma as decimal separator.
In a particular situation I need to replace the coma by point. I have this
code:
Columns("p:p").Select
Selection.NumberFormat = "General"
Selection.Replace What:=",", Replacement:="."
But nothing is happening. Column P still has comma as decimal separator.

What am I doing wrong?


I think this is failing because the comma is not actually part of the
contents of the cell, unless it is formatted as Text. In all number
formats the comma is 'virtual' - for display purposes only. In such
case, you will either need to build a Custom format that replaces the
comma with a dot or the cells will need to be formatted as text and
actual periods inserted were desired (probably not the way you want to
go).

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Comma replacement

On May 20, 4:32 am, Raul Sousa
wrote:
Unfortunately it does not work.
If do this operation by code, it does not work, Even if I format that column
as text.

But,
If I do it manually, this is, select the column, and set the format to
general. Then go to 'Edit', 'Replace', put a ',' in the Find what and a '.'
in the Replace With and then hit 'Replace All'.
It works

I think it should also work with this code.

"T Lavedas" wrote:
On May 19, 2:40 pm, Raul Sousa
wrote:
I am in Europe. I use by default coma as decimal separator.
In a particular situation I need to replace the coma by point. I have this
code:
Columns("p:p").Select
Selection.NumberFormat = "General"
Selection.Replace What:=",", Replacement:="."
But nothing is happening. Column P still has comma as decimal separator.


What am I doing wrong?


I think this is failing because the comma is not actually part of the
contents of the cell, unless it is formatted as Text. In all number
formats the comma is 'virtual' - for display purposes only. In such
case, you will either need to build a Custom format that replaces the
comma with a dot or the cells will need to be formatted as text and
actual periods inserted were desired (probably not the way you want to
go).


Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/


If the comma is actually in the text in the column, which your
statements about the manual operation proves is true, then the code
technique should work. A recorded macro for the manual operation
results in the following ...

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

I think the significant difference is the LookAt:=xlPart, which is
needed to find commas as *part* of another string. Maybe that's the
problem.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
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
Extract the text between last comma and last but one comma. Sreedevi Excel Worksheet Functions 2 March 5th 08 11:12 PM
Using comma inside the comma delimited text in Data Validation/Sou LasseH Excel Programming 5 December 14th 07 04:09 AM
Comma Delimited-need comma at beginnng & end Tattoo Excel Discussion (Misc queries) 2 December 11th 07 04:39 PM
Replacement T De Villiers[_45_] Excel Programming 0 July 21st 06 03:53 PM
Excel How do I create a comma delineated xls file to a comma delineated. Mark Excel Discussion (Misc queries) 0 November 26th 04 10:28 PM


All times are GMT +1. The time now is 06:36 PM.

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

About Us

"It's about Microsoft Excel"