delete characters values

  • Follow


Hello All!
I have a column with both characters values and numeric values. I
would like to delete from that column only character values.
Does someone know how to do it?

Thanks
in advance

regards
Emanuela
0
Reply Emanuela 1/10/2008 12:00:18 PM

This will require a custom vba function to strip out the non-numeric 
characters.

Paste the two functions below into a VBA module and call one of them in your 
query.  They work slightly different.

Field: fStripToNumbersOnly(YourFieldName)

Public Function fStripToNumbersOnly(ByVal varText As Variant) As String
'Takes input and returns only the numbers in the input.  Strips out
'all other characters.  Handles nulls, dates, numbers, and strings.

Const strNumbers As String = "0123456789"
Dim strOut As String
Dim intCount As Integer

   If Len(varText & "") = 0 Then
      strOut = ""

   Else
      varText = varText & ""
      For intCount = 1 To Len(varText)
         If InStr(1, strNumbers, Mid(varText, intCount, 1)) > 0 Then
            strOut = strOut & Mid(varText, intCount, 1)
         End If
      Next intCount
   End If

   fStripToNumbersOnly = strOut

End Function

Public Function NumPart(strIn As String) As String
'Faster than fStripToNumbersOnly but it doesn't handle nulls
'or other data types

Dim iPos As Integer
Dim strCh As String

NumPart = ""
   For iPos = 1 To Len(strIn)
      strCh = Mid(strIn, iPos, 1)
      If IsNumeric(strCh) Then
         NumPart = NumPart & strCh
      End If
   Next iPos

End Function

-- 
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Emanuela" <MANUP9@gmail.com> wrote in message 
news:132911af-fb51-445f-9124-c6aad384cb3c@m34g2000hsf.googlegroups.com...
> Hello All!
> I have a column with both characters values and numeric values. I
> would like to delete from that column only character values.
> Does someone know how to do it?
>
> Thanks
> in advance
>
> regards
> Emanuela 


0
Reply John 1/10/2008 12:35:26 PM


1 Replies
327 Views

(page loaded in 0.037 seconds)

Similiar Articles:
















7/19/2012 7:00:50 PM


Reply: