Can't convert . into , using find and replace?

Waimea

Active Member
Joined
Jun 30, 2018
Messages
465
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to convert "text"?? into number and I am trying to use find and replace but I get no results.

In cell X2 I have the string "133.81kWh".

In cell Y2 I have the following formula "=TRIM(LEFT(X2;LEN(X2)-3))"

I want to convert 133.81kWh to 133,81.

I have tried changing the format from text to number, I have tried to find and replace . with ,. I have also tried paste as special and multiplying the string with 1.0.

I am looking at a cell with the formula =ISNUMBER(Y2) which gives me FALSE.

How should I do to convert the string 133.81kWh to 133,81?
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Book1
XY
1
2133.81kWh133,81
Sheet1
Cell Formulas
RangeFormula
Y2Y2=0+LEFT(SUBSTITUTE(X2,".",","),LEN(X2)-3)
 
Upvote 0
Solution
Hi GraH,

thank you for your reply.

Your code is sweet and I was thinking about bumping my thread with the substitute function.

I just noticed that in the last row in my data I have

"206.36Wh".

Notice the missing "k" in "Wh.

Is there a good way to make the formula aware of kWh and Wh?
 
Upvote 0
one way
Book1
XY
2133.81kWh133,81
3206.36Wh206,36
Sheet1
Cell Formulas
RangeFormula
Y2:Y3Y2=0+LEFT(SUBSTITUTE(X2,".",","),IF(ISNUMBER(FIND("k",X2)),LEN(X2)-3,LEN(X2)-2))
 
Upvote 0
Hi GraH,

thank you again your for reply!

I see what you did there with the IF formula. If I wanted to divide values without "k" with 1000.

So that 206.36Wh becomes 0,20636kWh.

Where would I add the / 1000?
 
Upvote 0
would need to reverse & repeat some of the logics.
Book1
XY
2133.81kWh133,81
3206.36Wh0,20636
Sheet1
Cell Formulas
RangeFormula
Y2:Y3Y2=IF(ISNUMBER(FIND("k",X2)),SUBSTITUTE(LEFT(X2,LEN(X2)-3),".",",")+0,SUBSTITUTE(LEFT(X2,LEN(X2)-2),".",",")/1000)
 
Upvote 0
Hi GraH,

your last piece of code is great and it does exactly what I was trying to do.

Thank you very much GraH!
 
Upvote 0
Most welcome! Thanks for the feedback.
Maybe think to update your account information and add your Excel version.
Shorter solutions might be possible if you have 365 version.
 
Upvote 0
Hi GraH,

Thank you for your suggestion.

I am on Windows 10 and Excel 365.

Did you have anything shorter in mind?
 
Upvote 0
I was thinking about using LET. Not shorter, but maybe more readable.
Excel Formula:
LET (
Txt , substitute(X2,".",","),
kWh , isnumber(find("k",txt)),
L, len(txt)
Nmbr, If(kWh,left(txt, L-3), left(txt,L-2))+0,
If(kwh, Nmbr, Nmbr/1000)
)
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

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