Text Length

  • Thread starter Thread starter Soniya
  • Start date Start date
S

Soniya

Hi All,

How can I fix the lenght of a cell using code/

i have numbers formated as text im my column A which os
copied to another sheet and i want to fix the length to 7.

for eg if the number is 1 it should look like 0000001 and
if it is 12345 then 0012345

TIA
Soniya
 
Hi
I would format the column A as number (not as Text) and use a custom
format for displaying the values. e.g. the custom format
0000000
(entered in 'Format - Cells')

If you need a text value you may use the formula
=TEXT(A1,"0000000")
 
Soniya,

Use a custom number format. Select the cells that will contain
the values, then go to the Format menu and choose Cells. In that
dialog, choose the Number tab and in the Category list box,
choose Custom. In the format box, enter 0000000.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
for each cell in selection
Cell.Value = Right("'0000000" & cell.Text,7)
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top