+ Reply to Thread
Results 1 to 3 of 3

Getting info from a cell after the last letter appears...

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    491

    Getting info from a cell after the last letter appears...

    If you want to extract the numbers from a cell BUT the numbers always start after the last letter...

    How would you write a code to just extract the numbers?

    for example...

    24Macros113

    So after the letter S, 113 should be pulled from the cell.

    Any help would be appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Getting info from a cell after the last letter appears...

    Hi..

    Try this..
    Private Sub CommandButton1_Click()
        Dim objRegex, n
        Set objRegex = CreateObject("vbscript.regexp")
        With objRegex
            .Global = True
            .Pattern = "\d*\d$"
            For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
                Set myMatches = .Execute(Cells(i, 1))
                For Each n In myMatches
                        Cells(i, 2).Value = n
                Next n
            Next i
        End With
    End Sub
    Try the attached..
    Attached Files Attached Files
    Last edited by apo; 01-13-2014 at 10:03 PM.

  3. #3
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: Getting info from a cell after the last letter appears...

    This should do it:
    Option Explicit
    
    Public Sub Test()
      Dim x As Long
      
      x = GetNumber("24Macros113")
    End Sub
    
    Public Function GetNumber(x As String) As Long
      Dim NumberLength As Long
      
      NumberLength = 1
      
      Do While IsNumeric(Right(x, NumberLength))
        NumberLength = NumberLength + 1
      Loop
      GetNumber = CLng(Right(x, NumberLength - 1))
    End Function

+ 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] Want to count the number of times a particular letter appears within a range
    By dwhite30518 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-11-2013, 01:24 PM
  2. [SOLVED] HELP! Need to delete row ONLY if the letter N appears in BOTH column G and H
    By PLEASEHELPASAP in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-02-2012, 07:29 PM
  3. Replies: 5
    Last Post: 07-05-2012, 04:04 PM
  4. [SOLVED] Info box appears when open a spreadsheet
    By polarjaf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2012, 08:17 AM
  5. [SOLVED] Pulling a Letter from a cell and filling another cell with info
    By nick s in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 11-28-2005, 12:15 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