+ Reply to Thread
Results 1 to 3 of 3

text and numbers in cell

Hybrid View

  1. #1
    Henk
    Guest

    text and numbers in cell

    I want to delete the text in 30.000 cells from a cell which contains text and
    numbers. What is the easiest way to do so?

    Thanks

  2. #2
    Marcelo
    Guest

    RE: text and numbers in cell

    Hi Henk

    Copy this code and use the function Digitsonly(a2), copy down, copy and
    paste values

    hth
    regards from Brazil
    Marcelo

    *****************************************************
    Public Function DigitsOnly(sStr As String) As Variant
    Dim oRegExp As Object

    Set oRegExp = CreateObject("VBScript.RegExp")

    With oRegExp
    .IgnoreCase = True
    .Global = True
    oRegExp.Pattern = "\D"

    DigitsOnly = oRegExp.Replace(sStr, vbNullString)
    End With
    End Function
    ******************************************************



    "Henk" escreveu:

    > I want to delete the text in 30.000 cells from a cell which contains text and
    > numbers. What is the easiest way to do so?
    >
    > Thanks


  3. #3
    Gord Dibben
    Guest

    Re: text and numbers in cell

    Henk


    Sub RemoveAlphas()
    ' Remove alpha characters from a string.
    ' except for decimal points and hyphens.
    Dim intI As Integer
    Dim rngR As Range, rngRR As Range
    Dim strNotNum As String, strTemp As String

    Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
    xlTextValues)

    For Each rngR In rngRR
    strTemp = ""
    For intI = 1 To Len(rngR.Value)
    If Mid(rngR.Value, intI, 1) Like "[0-9.-]" Then
    'change to [0-9] if dec. pt. and hyphen not required
    strNotNum = Mid(rngR.Value, intI, 1)
    Else: strNotNum = ""
    End If
    strTemp = strTemp & strNotNum
    Next intI
    rngR.Value = strTemp
    Next rngR

    End Sub


    Gord Dibben MS Excel MVP


    On Wed, 9 Aug 2006 06:43:02 -0700, Henk <[email protected]> wrote:

    >I want to delete the text in 30.000 cells from a cell which contains text and
    >numbers. What is the easiest way to do so?
    >
    >Thanks



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1