+ Reply to Thread
Results 1 to 6 of 6

Revise VBA to Parse Out Text for entire sheet

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2016
    Posts
    20

    Revise VBA to Parse Out Text for entire sheet

    I have a VBA code that will parse out values in a text field in excel that starts with CS or cs followed by 8 digits and add those values in the same row in the empty columns to the right. What I want is for this macro to apply for the entire active sheet, search Column D for values that start with CS or cs followed by 8 digits and parse them out in the same row to the right starting at Column S going right as needed (there could up to 10 CS######## numbers in a single text cell that would need to be parsed out 10 columns to the right from Column S to Column AB)

    Thank you my crazy smart Forum members for you expertise!

    Here is the code that will parse out for a single active cell:

    Sub GetEventIndicators()

    Dim rExp As Object, allMatches As Object, match As Object
    Dim specialReqs As String, eventIndicator As String
    Dim row As Integer, col As Integer

    specialReqs = ActiveCell.Value
    row = ActiveCell.row
    col = ActiveCell.Column

    Set rExp = CreateObject("vbscript.regexp")
    With rExp
    .Global = True
    .MultiLine = False
    .Pattern = "[cC][sS]\d{8}"
    End With

    Set allMatches = rExp.Execute(specialReqs)

    For Each match In allMatches
    eventIndicator = match.Value
    'Debug.Print "Event Indicator: " & eventIndicator
    col = col + 1
    Cells(row, col).Value = UCase(eventIndicator)
    Next

    End Sub

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Revise VBA to Parse Out Text for entire sheet

    Hi jlanderson,

    We can do this problem a lot easier if you would supply a sample workbook showing the problem, with a few rows of data, and what you expect the answer to be. Also, could you edit your original post and select the code and click on the "#" icon that will put code tags around the code, so it is easier to read.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    06-17-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2016
    Posts
    20

    Re: Revise VBA to Parse Out Text for entire sheet

    I believe I have an attachment.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-17-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2016
    Posts
    20

    Re: Revise VBA to Parse Out Text for entire sheet

    Thanks Marvin - from one Seattlite to another - attachment is attached.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Revise VBA to Parse Out Text for entire sheet

    OK jlanderson,

    I put some minor changes to what you already had. Clear your yellow area on the second sheet and run the macro.
    Please Login or Register  to view this content.
    I hope my "hack" will give you enough example to do whatever else you need. The person who wrote this was pretty nerdy, using a CreateObject("vbscript.regexp").

    EventIndicators Answer.xlsm

  6. #6
    Registered User
    Join Date
    06-17-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2016
    Posts
    20

    Re: Revise VBA to Parse Out Text for entire sheet

    Like a charm!! Thanks Marvin. Can't wait to tell someone what a nerd they are!

+ 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] Revise formula to remove sapces from text in another cell
    By topaz99 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-01-2015, 01:30 PM
  2. [SOLVED] Remove Blanc Space, parse text, convert text to measurement
    By plans in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-25-2015, 07:50 PM
  3. need to convert details in entire sheet from text to number format
    By aleanboy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-25-2014, 02:42 PM
  4. Pasting entire row to a new sheet if cell contains certain text
    By bakerbaz04 in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 07-02-2014, 03:34 PM
  5. [SOLVED] Insert Row under cell containing text on entire active sheet
    By mgeddes in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-04-2013, 07:04 AM
  6. Replies: 5
    Last Post: 11-03-2012, 04:22 PM
  7. Macro to Parse Text - Import text to Excel from Multiple Text Files & Folders
    By Novice_To_Excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2012, 01:05 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