Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


number to text macro in EXCEL 2013

Posted on 2014-04-30
Medium Priority
Last Modified: 2014-05-01
Hi Experts
I need some help in properly write a macro in excel, I used to be able to do this in LOTUS123 but I can't figure it out in EXCEL.

I have 4400 lines of nun sequential numbers that I need to be text.  I tried just formatting the column as text but that did not hold the "0" in the last place on the number like I need, so I need to write a macro that will put the apostrophe in front of the number.

when I try to record a macro and the run it, it takes the data (number) from the cell where the macro was written and copies it down with the apostrophe.
So obviously that is no good.

how do I fix this.
Question by:KenBlessing
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40032594
Select your data and then run this macro.

sub cvtxt()
for each cel in selection
cel="'" & cel
next cel
end sub
LVL 35

Expert Comment

ID: 40032670
If you want to do it without a macro, you can use the TEXT function to convert the number to whatever format you want, then copy/paste values to retain the text value.

So if A1 had the value "1234" but you want it to show "001234", you'd do =TEXT(A1,"000000")
Then copy the formula and paste the value over it. It will now contain 001234.


Author Comment

ID: 40032992
sorry guys neither of these answers work for me.

what I have is :


What I whant is to do is put  the " '  " in front of the number


I hope that helps.

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40033023
You need to tell us more about "does not work"

Does it give an error?
Does it give wrong results?
Does it do nothing at all?

Author Comment

ID: 40033144
it does nothing at all
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40033155
You have to SELECT the range before running the macro

Author Comment

ID: 40033162
I did

Author Comment

ID: 40033167
Can you send a screen shot of the macro in the editor, maybe I put it in wrong.
Thank you

Author Comment

ID: 40033168
as I said I am really new to macros in excel
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40033186
While I upload a file

Right-click on the sheet tab name
Select View code
From the menu      Insert > Module
Paste this code in the VBA window
Close the VBA window
Select your range
Press Alt-F8
Select the macro name
Click on run
LVL 43

Accepted Solution

Saqib Husain, Syed earned 1000 total points
ID: 40033270
LVL 35

Assisted Solution

mvidas earned 1000 total points
ID: 40033631

You don't need to have the apostrophe before the value to force the formatting, and you don't need to use macros.

Insert a column next to your data. If your data is in column A, put the following into the (new) B1


That will show the value of cell A1 but with a forced three decimals like you want.

Then copy that formula down as far as the data goes.

Next, select your original cell range and change the format to Text.

Finally, copy your column B with the formatted numbers, go to your original range, and go to Paste -> Paste Special (the little arrow) -> and then the first Paste Values choice.

You can then delete the helper column B.

Your cells will now contain a permanent text version of the number formatted as you want it.


Author Closing Comment

ID: 40035551
Thank you both Saqib Husain, Syed and Matt both answers worked.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question