Finding right-most cell.
Didn't I answer this in another post which you could have modified to
NOT trim
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, 9:46*am, Bruno Campanini wrote:
gcotterl formulated the question :
Posted: Tue Sep 27, 2011 1:04 am * *Post subject: Find right-most
byte
--------------------------------------------------------------------------- -----
My text file has 1 million rows each 1,274 characters long.
How can I find the row having the number 9 in the right-most cell?
For example, how do I find the row indicated with an arrow?
0000000000000000000009999900000
0000000099999000000000000000000
9999000000000000000000000000000
0000000000000000000000000999900 *<----------------------
0000000000000099999990000000000
0000000000000000000000000000000
0000000000000000099999900000000
================================================
Public Sub DetectingRightmost9()
Dim i As Range, MaxRightPos As Long, RowNumber As Long
For Each i In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)
* * If InStrRev(i, 9) MaxRightPos Then
* * * * MaxRightPos = InStrRev(i, 9)
* * * * RowNumber = i.Row
* * End If
Next
MsgBox "Position " & MaxRightPos & " at Row " & RowNumber
End Sub
======================================
Bruno
|