Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6859051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:14:08+00:00 2026-05-27T02:14:08+00:00

I need to a) separate strings from numbers for a selection of cells and

  • 0

I need to

a) separate strings from numbers for a selection of cells

and

b) place the separated strings and numbers into different columns.

For example , Excel sheet is as follows:

     A1          B1
  100CASH     etc.etc.

The result should be:

   A1            B1          C1
  100           CASH       etc.etc.

Utilization of regular expressions will be useful, as there may be different cell formats,such as 100-CASH, 100/CASH, 100%CASH. Once the procedure is set up it won’t be hard to use regular expressions for different variations.

I came across a UDF for extracting numbers from a cell. This can easily be modified to extract string or other types of data from cells simply changing the regular expression.

But what I need is not just a UDF but a sub procedure to split cells using regular expressions and place the separated data into separate columns.

I’ve also found a similar question in SU, however it isn’t VBA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:14:09+00:00Added an answer on May 27, 2026 at 2:14 am

    See if this will work for you:

    UPDATED 11/30:

    Sub test()
    
        Dim RegEx As Object
        Dim strTest As String
        Dim ThisCell As Range
        Dim Matches As Object
        Dim strNumber As String
        Dim strText As String
        Dim i As Integer 
        Dim CurrCol As Integer
    
    
        Set RegEx = CreateObject("VBScript.RegExp")
        ' may need to be tweaked
        RegEx.Pattern = "-?\d+"
    
        ' Get the current column
        CurrCol = ActiveCell.Column
    
        Dim lngLastRow As Long
        lngLastRow = Cells(1, CurrCol).End(xlDown).Row
    
        ' add a new column & shift column 2 to the right
        Columns(CurrCol + 1).Insert Shift:=xlToRight
    
        For i = 1 To lngLastRow  ' change to number of rows to search
            Set ThisCell = ActiveSheet.Cells(i, CurrCol)
            strTest = ThisCell.Value
            If RegEx.test(strTest) Then
                Set Matches = RegEx.Execute(strTest)
                strNumber = CStr(Matches(0))
                strText = Mid(strTest, Len(strNumber) + 1)
                ' replace original cell with number only portion
                ThisCell.Value = strNumber
                ' replace cell to the right with string portion
                ThisCell.Offset(0, 1).Value = strText
            End If
        Next
    
        Set RegEx = Nothing
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help to insert comma separates strings into multiple columns into db.
I need to parse strings inputs where the columns are separated by columns and
I've an NSTextView with with several semi-colon separated strings. I need to find on
Trying to split this string 主楼怎么走 into separate characters (I need an array) using
I need to separate out a bunch of image urls from a document in
I need to separate our application into a light-weight gui application and a business
I need to take rows from two separate tables, and arrange them in descending
I need to pick up some numbers from lines with irregular length, like this:
I need to assign the results from a grep to an array... for example
Do I need a separate controller for the below? http://localhost/bookmarks --> bookmarks controller http://localhost/bookmark/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.