Results 1 to 13 of 13

Regex: Matching pattern to split a cell data

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-22-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    184

    Regex: Matching pattern to split a cell data

    Hi all,

    Basically I want to split data into each cell just the number without alphabet and special character.

    The data I want to split is:
    a=1,995.000 b=2,001.000 c=1,994.000 d=1,996.000 e=1,281

    Currently I have a set of code. New to regex, I need some help with the pattern.

    The code work well with the above data. But cant split if the data doesn't have "," or ".".
    ie, e=999. Search and trying a lot, I guess if the .pattern can be fixed then the code is complete.

    The code is as below:


    Sub onerowsplit()
        Dim i As Long, r As Range
            With CreateObject("VBScript.RegExp")
                 .Pattern = "\d+[\,\.](\d+)?"
                 .Global = True
              For Each r In Range(Range("k10").Value2)
                 If .test(r.Value) Then
                    For i = 0 To .Execute(r.Value).Count - 1
                        r(, i - 5).Value = Format(.Execute(r.Value)(i), "#")
                    Next
                 End If
              Next
            End With
    End Sub
    By Ab33

    Please put the data in column K.

    If you want to see attachment, it below.


    http://www.mrexcel.com/forum/excel-q...ml#post3922941
    Attached Files Attached Files
    Last edited by DavidRoger; 08-30-2014 at 08:27 AM. Reason: Review questions

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Regex - establishing a pattern
    By twckfa16 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-30-2014, 11:06 AM
  2. [SOLVED] RegEx pattern to extract multiplelines title in TXT file
    By p24leclerc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2014, 08:39 PM
  3. [SOLVED] RegEX VBA Split Method
    By goss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-02-2013, 05:03 PM
  4. Pattern Matching within a dynamic data set
    By sawb23 in forum Excel General
    Replies: 0
    Last Post: 02-03-2013, 04:40 AM
  5. Need a new regex .pattern for comparison code
    By Swiss Cheese in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2012, 09:16 PM

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