+ Reply to Thread
Results 1 to 5 of 5

replace the comma separator to a dot and dot to a comma at the same time

  1. #1
    Registered User
    Join Date
    02-25-2005
    Posts
    38

    replace the comma separator to a dot and dot to a comma at the same time

    I have a set of data in Column A1 to A100

    i need a macro to replace the comma separator to a dot but at the same time, dot separator to a comma separator ?
    but if the number has only comma separator or only dot separator no action should be taken

    for example
    1,765.12 should be like 1.765,12

    but
    if the number contains only dot or only comma no action should be taken
    for example

    1765,12 number should not be changed




    please help
    Last edited by barkiny; 07-24-2010 at 01:38 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: help please- replace the comma separator to a dot and dot to a comma at the same

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: replace the comma separator to a dot and dot to a comma at the same time

    Assuming the value you're starting with is text,

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1, ",", "|"), ".", ","), "|", ".")
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    07-24-2010
    Location
    Ostrava, Czech republic
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: replace the comma separator to a dot and dot to a comma at the same time

    Sub commadot()
    Dim vyraz$, znak$
    Dim f!
    Dim g%, delkas%, jecarka%, jetecka%

    For f = 1 To 100
    vyraz = Range("a" & f)
    delkas = Len(vyraz)
    jecarka = InStr(vyraz, ",")
    jetecka = InStr(vyraz, ".")

    If jecarka And jetecka Then
    For g = 2 To Len(vyraz)
    znak = Mid(vyraz, g, 1)
    If znak = "," Then vyraz = Left(vyraz, g - 1) & "." & Right(vyraz, delkas - g): GoTo dalsi
    If znak = "." Then vyraz = Left(vyraz, g - 1) & "," & Right(vyraz, delkas - g)
    dalsi:
    Next g
    Range("a" & f) = vyraz
    End If

    Next f
    End Sub

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: replace the comma separator to a dot and dot to a comma at the same time

    Welcome to the forum, Exelsior.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1