Number to Text Error

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Sometimes I receive excel files where various columns should have been stored as text when they converted them to excel and if it is only a couple of cells that are incorrect then I click on the cell and then formula bar and type an ' at the start of the number to change it to text i.e 7000 ends up as '7000.

I have tried formatting the cells to do this but nothing happens.

On large files I save them as text and then reopen them changing the specific columns to text, however I would prefer to have a script that I can run based on whatever column I am in, it would change that column to the right format.

Thanks.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Will this do it?
Code:
Sub NumsToTex()
Dim rng As Range
On Error Resume Next
With ActiveCell.EntireColumn
    Set rng = .SpecialCells(xlCellTypeConstants, 1)
    If Not rng Is Nothing Then
        On Error GoTo 0
        For Each c In rng
            c.Value = "'" & c.Value
        Next c
   End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

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