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 / September 2006

Tip: Looking for answers? Try searching our database.

Extract and copy only letters from range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J.W. Aldridge - 30 Sep 2006 16:05 GMT
Hi. I have a list in column a of letters and numbers. I want to copy
the cells where there are letters (4letters) only and place them in the
same positon in column H - excluding all numbers.

Formula or vb?
Any clues?
Tom Ogilvy - 30 Sep 2006 17:41 GMT
An example of you data would help, but

Sub ABC()
Dim rng As Range, cell As Range
Dim s As String, s1 As String
Dim sChr As String, i as Long
Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
For Each cell In rng
 s1 = ""
 s = cell.Text
 If Len(s) >= 4 Then
   For i = 1 To Len(s)
    sChr = Mid(s, i, 1)
    If sChr Like "[A-Za-z]" Then
       s1 = s1 & sChr
    End If
   If Len(s1) >= 4 Then
        Cells(cell.Row, "H").Value = s1
   End If
   Next
 End If
Next

End Sub

should work.  If you mean only cells that are completely text and the range
contains only cells that are completely numbers stored as numbers or text :

for example
Header1
123
456
689

Header3
234
567
891

Then it would be:

Sub AAAA()
Dim rng as Range, cella s Range
Set rng = Range(Cells(1, 1), Cells(Rows.Count,
1).End(xlUp)).SpecialCells(xlConstants,xlTextValues)
for each cell in rng
  cell.offset(0,7).Value = cell.Value
Next
End Sub

Signature

Regards,
Tom Ogilvy

> Hi. I have a list in column a of letters and numbers. I want to copy
> the cells where there are letters (4letters) only and place them in the
> same positon in column H - excluding all numbers.
>
> Formula or vb?
> Any clues?
J.W. Aldridge - 30 Sep 2006 22:32 GMT
worked like a charm....

Thanx !
 
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.