Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default code dropping zeros in number strand

I'm moving numbers from one column to another and using the below code. When
the number is being moved by the code from column H to column I it drops the
zeros at the beginning of the number. How can I fix this? Also I need to
change the criteria to move any number that is greater than 8 characters. I
tried changing the 13 to 8 or but that did not work for m. Thanks

Set rng = Range(Cells(2, "H"), Cells(Rows.Count, "H").End(xlUp))
For Each cell In rng
If Len(cell) = 13 Then
cell.Offset(0, 1).Value = cell.Value
cell.ClearContents
End If
Next


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default code dropping zeros in number strand

If you format the detination cells as Text beforerunning the macro, the
leading zeros will be preserved..


also:

if len(cells.value) 8 then
--
Gary''s Student


"SITCFanTN" wrote:

I'm moving numbers from one column to another and using the below code. When
the number is being moved by the code from column H to column I it drops the
zeros at the beginning of the number. How can I fix this? Also I need to
change the criteria to move any number that is greater than 8 characters. I
tried changing the 13 to 8 or but that did not work for m. Thanks

Set rng = Range(Cells(2, "H"), Cells(Rows.Count, "H").End(xlUp))
For Each cell In rng
If Len(cell) = 13 Then
cell.Offset(0, 1).Value = cell.Value
cell.ClearContents
End If
Next


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
Dropping Zeros Rene'' Excel Worksheet Functions 8 April 23rd 07 08:32 PM
Formula Dropping Leading Zeros Computer Lady Excel Programming 3 January 26th 06 11:13 PM
Excel file saved as csv - dropping zeros Kathy Excel Discussion (Misc queries) 3 February 18th 05 07:15 PM
Trailing zeros are dropping off mjd918 Excel Programming 0 October 18th 04 09:27 PM
Dropping leading zeros in character fields. Ron K Excel Programming 2 September 11th 03 07:41 AM


All times are GMT +1. The time now is 06:25 PM.

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

About Us

"It's about Microsoft Excel"