Text

mjbryant

New Member
Joined
Feb 17, 2003
Messages
27
I have a file of about 5,000 records. They are people's names. Some of the records include characters such as " or , or # or 123... I want a file that has only text in it (A-Z)...how do I delete these records that are not pure text?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
There isn't any single function that can test for alpha characters only like what is available for numbers (IsNumeric) or Dates (IsDate). But, what you can do is use the ASC function to evaluate the Ascii value of each character within a string.

You'll want to tweak this to match your needs.

Code:
Private Function DelNonText()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim strVal, strSQL As String
Dim x As Integer

Set dbs = CurrentDb()
strSQL = "SELECT * FROM Table1"
Set rs = dbs.OpenRecordset(strSQL, dbOpenDynaset)

With rs
  Do Until rs.EOF
    strVal = .Fields(1).Value
    For x = 1 To Len(strVal)
      Select Case Asc(Mid(strVal, x, 1))
        Case 65 To 90:       ' Upper Case Alphabet
        Case 97 To 122:      ' Lower Case Alphabet
        Case Else
          .Delete
          Exit For           ' Found one stop checking
      End Select
    Next x

    .MoveNext
  Loop
End With

Set rs = Nothing
Set dbs = Nothing
End Function

Mike
 
Upvote 0

Forum statistics

Threads
1,223,497
Messages
6,172,638
Members
452,467
Latest member
colelkay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top