+ Reply to Thread
Results 1 to 7 of 7

Parse data to 2 columns and remove unwanted data with VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    05-24-2013
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    8

    Parse data to 2 columns and remove unwanted data with VBA

    I am dumping data from a text file that looks like this in Excel

    Bob North PAYEE 6S290 $********2,103.00
    Joe Smith PAYEE 6G621 $**********220.21
    Treasurer PAYEE 0001635838 $*******20,000.00
    Dolly South PAYEE D36922 $**********894.25
    Jim East PAYEE 0020807012 $*******20,000.00
    Billy Bob PAYEE D36921 $*******20,000.00

    All the data is in column C. All I need is the data below. The name would be in column C and the number would be in column D. What would be the easiest way to accomplish this with vba. I tried using text to columns but some of the Payee data would think it is a number and transpose it to look like this example( 6S290 would look like 6.00E+90).

    Bob North
    Joe Smith
    Treasurer 0001123467
    Dolly South
    Jim East 0098765423
    Billy Bob

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Parse data to 2 columns and remove unwanted data with VBA

    If your data starts in A1 then paste this formula in B1 and fill down

    Formula: copy to clipboard
    =LEFT(A1,FIND("PAYEE",A1)+15-ISERROR(FIND(" 00",A1))*10)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    05-24-2013
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Parse data to 2 columns and remove unwanted data with VBA

    Thanks for the quick reply.

    I was hoping to do this in vba and I need the name in one column and just the number in a different column. No payee.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,318

    Re: Parse data to 2 columns and remove unwanted data with VBA

    Possibly...
    Sub testparse()
        Dim v As Variant, w As Variant
        Dim x As Long
        Dim a As String, b As String
    
        With ActiveSheet
            v = Intersect(.Columns("C"), .UsedRange)
            w = v
            For x = LBound(v) To UBound(v)
                a = Left(v(x, 1), InStr(1, v(x, 1), "PAYEE") - 2)
                b = Mid(v(x, 1), InStr(1, v(x, 1), "PAYEE") + 6, InStr(1, v(x, 1), " $*") - (InStr(1, v(x, 1), "PAYEE") + 6))
                v(x, 1) = a
                If IsNumeric(b) Then
                    w(x, 1) = b
                Else
                    w(x, 1) = ""
                End If
            Next x
            Intersect(.Columns("C"), .UsedRange) = v
            Intersect(.Columns("C"), .UsedRange).Offset(, 1) = w
        End With
    End Sub

  5. #5
    Registered User
    Join Date
    05-24-2013
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Parse data to 2 columns and remove unwanted data with VBA

    That is leaving some of the data I don't want (7D260) and some of the data looks like 7.00E+29 & 6.00E+81.

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,318

    Re: Parse data to 2 columns and remove unwanted data with VBA

    In your example, what is the criteria for keeping the numbers after the Treasurer and Jim East? I assumed numeric ...?
    As for the scientific notation, you probably need to format column d as text beforehand.

  7. #7
    Registered User
    Join Date
    05-24-2013
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Parse data to 2 columns and remove unwanted data with VBA

    Yes, I formatted column D and it fixed everything. Thanks everyone for you help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Can some one please help me with V.B.A code to remove the unwanted data in the sheet.
    By boddulus in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-08-2014, 12:30 PM
  2. [SOLVED] I have two columns of data that I need parse data from every 1 second to every 10 minutes.
    By reesjordan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-17-2014, 06:15 PM
  3. [SOLVED] Macro Remove Unwanted Data
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2013, 06:01 AM
  4. Formula to remove unwanted data & rearrange last name & first name in a cell
    By rbecker69 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 03:12 AM
  5. [SOLVED] Need macro to remove unwanted data from large tables
    By s4driver in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-26-2013, 08:07 AM
  6. remove unwanted data
    By ahmedalhoseny in forum Excel General
    Replies: 1
    Last Post: 06-14-2010, 04:51 AM

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