Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Formatting column

I've got an Excel workbook that contains many license numbers and I need to
format the column so that if a license number has several 0s in front, they
aren't automatically truncated by Excel. I tried general, number, and text
formats but they truncate leading 0s. Any ideas? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Formatting column

You may try running the code below which should effectively remove all
leading zero from the selected cells.

Sub truncate_zero()
Dim cell As Object, tmp
For Each cell In Selection.Cells
tmp = cell.Value
If Left(tmp, 1) = 0 Then
Do Until Left(tmp, 1) < 0
tmp = Right(tmp, Len(tmp) - 1)
Loop
cell.Value = tmp
End If
Next
End Sub


Regards,
Edwin Tam

http://www.vonixx.com


"Brent E" wrote:

I've got an Excel workbook that contains many license numbers and I need to
format the column so that if a license number has several 0s in front, they
aren't automatically truncated by Excel. I tried general, number, and text
formats but they truncate leading 0s. Any ideas? Thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
have B column turn red on conditional formatting of E column: jsharper Excel Worksheet Functions 2 September 7th 09 10:42 PM
Formatting cells in a column with conditional formatting? shamor Excel Discussion (Misc queries) 8 May 19th 08 10:11 PM
formatting a column S Davis[_2_] Excel Worksheet Functions 4 March 4th 07 03:02 AM
column to column conditional formatting won't work, need formula rrupp Excel Worksheet Functions 1 August 23rd 05 10:06 PM
Column Formatting G4 Excel Worksheet Functions 1 August 9th 05 09:34 AM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"