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

I am trying to remove the leading zeros from a column of values, the code
below works but it also seems to be removing the ending zeros as well.

I tried this which does not workResult1 = Replace(Left(Cells(x, 2), "00", ""))

here is my code.
For x = 2 To 4000
Result1 = Replace(Cells(x, 2), "00", "")
Cells(x, 2) = Result1
Next x

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default REPLACE HELP


For x = 2 To 4000
result1 =Cells(x, 2)
do while left(result1,1)="0"
result1 = mid(result1,2)
loop
Cells(x, 2) = Result1
Next



"Rpettis31" wrote in message
...
I am trying to remove the leading zeros from a column of values, the code
below works but it also seems to be removing the ending zeros as well.

I tried this which does not workResult1 = Replace(Left(Cells(x, 2), "00",
""))

here is my code.
For x = 2 To 4000
Result1 = Replace(Cells(x, 2), "00", "")
Cells(x, 2) = Result1
Next x

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default REPLACE HELP

Your values are text (real numbers would not preserve leading zeroes unless
formatted to do so)? Why? Why not use real numbers and format the cells to
show the number the way you want it to look? Then you wouldn't need any code
as Excel would handle everything for you.

--
Rick (MVP - Excel)


"Rpettis31" wrote in message
...
I am trying to remove the leading zeros from a column of values, the code
below works but it also seems to be removing the ending zeros as well.

I tried this which does not workResult1 = Replace(Left(Cells(x, 2), "00",
""))

here is my code.
For x = 2 To 4000
Result1 = Replace(Cells(x, 2), "00", "")
Cells(x, 2) = Result1
Next x


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
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
Can I replace a ' at the beginning of a text cell using Replace Hilde Excel Discussion (Misc queries) 4 September 10th 07 06:22 PM
How to Replace multiple words to replace using excell ramsun Excel Programming 1 August 10th 06 01:52 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM


All times are GMT +1. The time now is 07:25 AM.

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"