TextToNumbers

Spoulis19

Board Regular
Joined
Dec 31, 2010
Messages
56
could somebody please explain me why the
below code of macro converts
from text to numbers the 24, but not the 24,5

Sub textonumbers()
Dim tempR As Range
'find a blank cell
Set tempR = Cells(ActiveSheet.UsedRange.Count +
1)
'format the selection as a number
Selection.NumberFormat = "0"
'copy tempR, which is a blank cell
tempR.Copy
'add tempR's value to the cells in the selection
Selection.PasteSpecial Paste:=xlValues,
operation:=xlAdd
'clear the clipboard
Application.CutCopyMode = False


End Sub​
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
aHA. You need to go into the options menu, international (or format, I don't know because I have 2003) and change it from "." to ","
 
Upvote 0
Hi,

try this

Code:
Sub test()
    Dim aCell As Range
    
    For Each aCell In Selection
        aCell = aCell + 0
    Next aCell
     
End Sub

Here also , (comma) as decimal point

M.
 
Upvote 0
I don't think he has excel configured to know "," AS a decimal point. It may still think it is "."
 
Upvote 0
I don't think he has excel configured to know "," AS a decimal point. It may still think it is "."

My Excel 2010 has , (comma) as decimal point, but Excel behaves strangely.

If you turn-on the macro recorder and do mannualy copy and paste special add it works perfect. But if you run the macro that was recorded it doesnt work...

So i tried the work-around i posted above and it worked perfectly.

M.
 
Upvote 0
Dear Marcelo you are absolutely right, your macro works!

If you suggest any books except from mrexcel, j-walk and allbright that I have already read them, please let me know.

Kinds Regards
 
Upvote 0
Dear Marcelo you are absolutely right, your macro works!

If you suggest any books except from mrexcel, j-walk and allbright that I have already read them, please let me know.

Kinds Regards

Spoulis,

Bill Jelen books are also great, but apart reading books follow the threads in this site and you'll learn a lot!

All the best

M.
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,610
Members
452,931
Latest member
The Monk

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