Results 1 to 4 of 4

UDF to Split Text String

Threaded View

  1. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: UDF to Split Text String

    This aren't UDFs, they are reformatting macros. Run this on a copy of your values in column A and see if they do what you wish.

    Option Explicit
    Option Compare Text
    
    Sub ParseDataValue()
    'Author:    Jerry Beaucaire
    'Date:      1/27/2010
    'SUMMARY:   Reduce text strings to specific values
    Dim LR As Long, i As Long, v As Long
    Dim RNG As Range, MyArr, Vals
    
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Set RNG = Range("A:A").SpecialCells(xlCellTypeConstants)
    MyArr = Application.WorksheetFunction.Transpose(RNG.Value)
    
        For i = 1 To LR
            Vals = Split(MyArr(i), " ")
            Cells(i, "A") = Vals(0)
            Cells(i, "B") = Format(Vals(UBound(Vals)), "0.00")
        Next i
    
    Columns("B:B").NumberFormat = "0.00"
    Columns.AutoFit
    End Sub
    
    Sub ParseDataSTATUS()
    'Author:    Jerry Beaucaire
    'Date:      1/27/2010
    'SUMMARY:   Reduce text strings to specific status report
    Dim LR As Long, i As Long
    Dim RNG As Range, MyArr
    
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Set RNG = Range("A:A").SpecialCells(xlCellTypeConstants)
    MyArr = Application.WorksheetFunction.Transpose(RNG.Value)
    
        For i = 1 To LR
            Cells(i, "A") = Left(MyArr(i), InStr(MyArr(i), " ") - 1)
            
            If InStr(MyArr(i), "Very Limited") > 0 Then
                Cells(i, "B") = "Very Limited"
            ElseIf InStr(MyArr(i), "Not Limited") > 0 Then
                Cells(i, "B") = "Not Limited"
            ElseIf InStr(MyArr(i), "Somewhat Limited") > 0 Then
                Cells(i, "B") = "Somewhat Limited"
            End If
    
        Next i
    
    Columns.AutoFit
    End Sub
    Last edited by JBeaucaire; 01-27-2010 at 01:32 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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