Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

VB Right

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Suzanne - 09 Dec 2007 06:07 GMT
I need a fix to select only the 4 right digits in cells that are not empty in
a column (Range J2:??)

Thanks -- Suz
Rick Rothstein (MVP - VB) - 09 Dec 2007 09:49 GMT
>I need a fix to select only the 4 right digits in cells that are not
> empty in a column (Range J2:??)

I'm not entirely clear on the meaning of "fix" and "select" as you used them
in your question. This formula...

=RIGHT(J2,4)

will return up to the right-most 4 characters (that is, from zero to four
characters depending on the cell's content) in a cell (J2 for the above
example usage) and can be copied down to handle the other cells in the
column. Is that what you are looking for?

Rick
Joel - 09 Dec 2007 12:37 GMT
Sub fix_ColumnJ()

LastRow = Cells(Rows.Count, "J").End(xlUp).Row
For RowCount = 2 To LastRow
  data = Trim(Range("J" & RowCount))
  'get last four didgits of text
  If Len(data) >= 4 Then
     data = Trim(Right(data, 4))
  End If
  'convert to number if necessary
  'comment out if not necessary
  If IsNumeric(data) Then
     Number = Val(data)
  End If
  Range("J" & RowCount) = Number
Next RowCount
End Sub

> >I need a fix to select only the 4 right digits in cells that are not
> > empty in a column (Range J2:??)
[quoted text clipped - 10 lines]
>
> Rick
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.