Number Format Issue

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,461
I have a column that has text numbers in it and I am having trouble converting the text to numbers.

I have tried:

1.Number Format, General Format

2. This macro:
Code:
[COLOR=#0000ff]Sub[/COLOR] FormatTexttoNumbers()
   [COLOR=#0000ff] Dim[/COLOR] Col [COLOR=#0000ff]As [/COLOR]Range
[COLOR=#0000ff]        On Error Resume Next[/COLOR]
          [COLOR=#0000ff]  Set[/COLOR] Col = Application.InputBox("Please select a column...", Type:=8)
          [COLOR=#0000ff]  Set[/COLOR] Col = Columns(Col.Cells(1).Column)
        Col.NumberFormat = "0.00"
        Col.Value = Col.Value
[COLOR=#0000ff]  On Error GoTo 0[/COLOR]
[COLOR=#0000ff]End Sub[/COLOR]

3. =NUMBERVALUE(A1)

4. Copy and Paste As Values

5. They test FALSE for =ISNUMBER()

They look like this:


Excel 2012
CD
2100.19992
31011.4988
410.298348
51028.7972
6103.19696
710.793276
81074.5930
91079.6926
101094.0914
11111.98933
121130.0884
13113.88789
14116.78568
151171.4853
Sheet1


does anyone know why this would be occurring or how to fix my issue? Any help would be appreciated.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Did you try highlighting the cells and running selection.value = selection.value in the immediate window?


If that doesn't work change the format to number and run it again
 
Upvote 0
Try copy a zero and pastespecial add values over the range
 
Upvote 0
sheetspread & henrik2h,

Thank you for the assistance. I found that the issue was this:

Column C & D have two trailing spaces for every value meaning that a cell value that appears to be 100.1 is actually “100.1 “ . These two trailing spaces prevented me from simply changing the cell format to “Number Format”. Instead I had do this:

1. Use these two formulas to get rid of trailing spaces=LEFT(C2,LEN(C2)-2) & =LEFT(D2,LEN(D2)-2) (Copy Down)
2. Use Selection.Value = Selection.Value

So when I tried to use Selection.Value = Selection.Value initially it would not work because these values were not recognized as numbers.

Note: I tried using the Trim() Function first and it failed to correct the issue...
 
Last edited:
Upvote 0
Glad you got it working, but when I try:


Excel 2010
A
13
244
322
4100.1
5220.33
6234.56
7=SUM(A1:A6)
Sheet1


(first formatting the A column cells as text, you can see the sigma button and range returns the formula)

then I format the column as number:


Excel 2010
A
13
244
322
4100.1
5220.33
6234.56
7=SUM(A1:A6)
Sheet1


still no change, but if I then run the selection.value = selection.value after highlighting the A column numbers:


Excel 2010
A
13.00
244.00
322.00
4100.10
5220.33
6234.56
7623.99
Sheet1
Cell Formulas
RangeFormula
A7=SUM(A1:A6)


No trim needed (some of the numbers had preceding or ending extra spaces)

Also, did ctrl-h find space, replace with nothing work?
 
Upvote 0

Forum statistics

Threads
1,203,212
Messages
6,054,184
Members
444,707
Latest member
cahayagalax

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