PC Review


Reply
Thread Tools Rate Thread

Delete rightmost zeroes

 
 
gcotterl
Guest
Posts: n/a
 
      27th Sep 2011
How can I delete all of the zeroes to the right of the last 9 in each
row?

For example, here are some rows:

0000000000000000000009990000000
0000000099099000000000000000000
9999000000000000000000000000000
0000000000000000000000000099900
0000000000000099999990000000000
0900000000000000000000000000000
0000000000000000099999000000000

This is result I'm looking for:

000000000000000000000999
0000000099099
9999
00000000000000000000000000999
000000000000009999999
09
0000000000000000099999

Then, how do I find the longest row?
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      27th Sep 2011
Sub deleterightzerosSAS() 'assumes TEXT formatting
For Each c In _
Range("a1:a" & Cells(Rows.Count, 1).End(xlUp).Row)
c.Value = Left(c, InStrRev(c, 9))
If Len(c) > lenc Then
maxrow = c.Row
lenc = Len(c)
End If
Next c
MsgBox "max " & lenc & " found at row " & maxrow
End Sub







On Sep 27, 4:28*am, gcotterl <gcott...@co.riverside.ca.us> wrote:
> How can I delete all of the zeroes to the right of the last 9 in each
> row?
>
> For example, here are some rows:
>
> 0000000000000000000009990000000
> 0000000099099000000000000000000
> 9999000000000000000000000000000
> 0000000000000000000000000099900
> 0000000000000099999990000000000
> 0900000000000000000000000000000
> 0000000000000000099999000000000
>
> This is result I'm looking for:
>
> 000000000000000000000999
> 0000000099099
> 9999
> 00000000000000000000000000999
> 000000000000009999999
> 09
> 0000000000000000099999
>
> Then, how do I find the longest row?


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      27th Sep 2011
On Sep 27, 9:19*am, Bruno Campanini <bruno...@libero.it> wrote:
> gcotterl has brought this to us :
>
>
>
>
>
>
>
>
>
> > How can I delete all of the zeroes to the right of the last 9 in each
> > row?

>
> > For example, here are some rows:

>
> > 0000000000000000000009990000000
> > 0000000099099000000000000000000
> > 9999000000000000000000000000000
> > 0000000000000000000000000099900
> > 0000000000000099999990000000000
> > 0900000000000000000000000000000
> > 0000000000000000099999000000000

>
> > This is result I'm looking for:

>
> > 000000000000000000000999
> > 0000000099099
> > 9999
> > 00000000000000000000000000999
> > 000000000000009999999
> > 09
> > 0000000000000000099999

>
> > Then, how do I find the longest row?

>
> If you want to preserve leftmost zeroes, please modify
> Don Guillet's formula as follows:
>
> For Each c In Range("a1:a" & Cells(Rows.Count, 1).End(xlUp).Row)
> * * c.Value = "'" & Left(c, InStrRev(c, 9))
> * * If Len(c) > lenc Then
> * * * * maxrow = c.Row
> * * * * lenc = Len(c)
> * * End If
> Next c
> MsgBox "max " & lenc & " found at row " & maxrow
>
> Bruno


Didn't need that. I thought I qualified mine with
'assumes TEXT formatting
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Next-To-Last, Non-Blank, Rightmost Value in a Row Dave The Favorite Microsoft Excel Worksheet Functions 6 30th Nov 2009 04:41 PM
Formula to delete rightmost N characters Eric_NY Microsoft Excel Misc 2 14th Aug 2009 04:06 PM
Rightmost Column =?Utf-8?B?QmlsbENQQQ==?= Microsoft Excel Misc 5 14th Nov 2007 07:08 PM
how to delete the 4 rightmost digits from a cell =?Utf-8?B?Y2hhcmxlbmU=?= Microsoft Excel Worksheet Functions 4 29th Jun 2006 03:11 PM
Re: Delete cells in row A with just zeroes Tim Zych Microsoft Excel Programming 0 16th Jul 2003 10:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 PM.