Dot is replaced by a comma

SonnyTito

New Member
Joined
Sep 23, 2015
Messages
9
Hi all,
I have written some VBA code where a user selects a code from a dropbox.
The selected code is eg. 01.01
If I put this choice into a variable and put the variable content into a cell, 01.01 becomes 1,01, which is not what I want.

I have simulated this in an easy way with following code:
Range("A5").Value = Range("A1").Value

Even if A1 contains 01.01, the cell contact of A5 will be 1,01

Any suggestions how to prevent this?

Thank you !
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
it will be in control panel, country settings generally

otherwise options > advanced and scroll down to editing options, look at use system seperators
 
Upvote 0
I have written some VBA code where a user selects a code from a dropbox.
The selected code is eg. 01.01
If I put this choice into a variable and put the variable content into a cell, 01.01 becomes 1,01, which is not what I want.

I have simulated this in an easy way with following code:
Range("A5").Value = Range("A1").Value

Even if A1 contains 01.01, the cell contact of A5 will be 1,01

Any suggestions how to prevent this?
Assuming cell A5 is where you are putting this value, execute this code line before you put the 01.01 value into it...

Range("A5").NumberFormat = "@"

That will set the cell's format to TEXT so that Excel won't try to interpret the code a number.
 
Upvote 0
Assuming cell A5 is where you are putting this value, execute this code line before you put the 01.01 value into it...

Range("A5").NumberFormat = "@"

That will set the cell's format to TEXT so that Excel won't try to interpret the code a number.


Thank you Rick.
This works fine
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

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