Swap two values in a cell?

Jyggalag

Active Member
Joined
Mar 8, 2021
Messages
445
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi all,

I currently have these values in a larger format from rows J - N. I have made a small example of my data here:

1661417218878.png


I essentially want to swap my "." with my "," in every cell, if applicable.

If not applicable, I want to replace my "." with a "," and my "." with a ","

Does this make sense, is it possible?

Thank you! :)
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
UPDATE:

I have found this in "currency" that could solve my problem. However, the format "1,234.10" is not available. any idea why?

1661417984179.png
 
Upvote 0
UPDATE:

I have found this in "currency" that could solve my problem. However, the format "1,234.10" is not available. any idea why?

View attachment 72457
Edit* It does not work anyway. I just tried to apply the "1.234,10" format to a cell in which I had the value "2,007.30" and it remains at this value and does not change...
 
Upvote 0
Is it Regional Setting in Control Panes? Have you tried it?
I tried this:

1661420715685.png


It does not work.

I do not think regional settings will help either.

Right now it seems that excel does not even recognize 2,007.30 as a value at all :( Even if i change the formatting "General" to "Number"!

Very strange indeed. Would truly appreciate any solution that can solve this without me manually editing 5000 rows :( haha
 
Upvote 0
Try Find & Replace tool to convert text into number:
Select the range.
Ctrl-H

1) First to remove thousand delimiter:
Find what: ","
Replace with: <input nothing here>

2) Then replace "." with ","
Find what: "."
Replace with: ","
 
Upvote 0
Solution
Good day

As per bebo021999 suggestion try the below:

VBA Code:
Sub rplce()
Selection.Replace What:=",", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:=" ", Replacement:=".", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
End Sub

Just select your range and run the code...
 
Upvote 0
Try Find & Replace tool to convert text into number:
Select the range.
Ctrl-H

1) First to remove thousand delimiter:
Find what: ","
Replace with: <input nothing here>

2) Then replace "." with ","
Find what: "."
Replace with: ","
This worked. Can't believe I did not think of this haha :D

I just inserted a random value for "," and then I replaced all . with , and after this i replaced the random value with a .

Amazing. Thanks! :)
 
Upvote 0
Good day

As per bebo021999 suggestion try the below:

VBA Code:
Sub rplce()
Selection.Replace What:=",", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:=" ", Replacement:=".", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
End Sub

Just select your range and run the code...
I also really like this idea, although I'm not sure how to implement it! Is this a VBA code that I attach to a macro? And if so, how would I edit it if I only wanted it to make the replacements in column J-N?
 
Upvote 0
I also really like this idea, although I'm not sure how to implement it! Is this a VBA code that I attach to a macro? And if so, how would I edit it if I only wanted it to make the replacements in column J-N?

Hi There...

Yes... so steps to follow will be...

1. Hit Alt+F11 to open the VBA Editor...
2. Insert a module
3. Paste the code below into the window

1.png


VBA Code:
Sub Find_Replace()
    Columns("J:N").Select
        Selection.Replace What:=",", Replacement:=" "
        Selection.Replace What:=".", Replacement:=","
        Selection.Replace What:=" ", Replacement:=".", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
                ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
End Sub

4. Close the VBA Editor

On your worksheet you can then Alt+F8 to run the macro or you can assign a button to it.

2.png

To assign a button you would need to have the Developer Tab Open. I assigned my test to a button but Alt+F8 will also work.
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,135
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top