+ Reply to Thread
Results 1 to 10 of 10

VBB Code to Trim Check number from Text

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VBB Code to Trim Check number from Text

    Hello

    I need VB Code to Go thru text in column E

    Look for 6 digit check number
    If it finds, then put that check number in column D as shown


    D8=972201
    D9=995955

    Please let me know if you have any questions.
    Thanks.

    R
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this !


    According to your attachment a VBA demonstration as a beginner starter :

    PHP Code: 
    Sub Demo1()
             
    Dim Rc As RangeV
        
    For Each Rc In Sheet1.UsedRange.Columns(Sheet1.UsedRange.Column).Cells
            V 
    Right(Rc6)
            If 
    V Like "######" Then Rc(10) = V
        Next
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 11-06-2022 at 01:23 PM. Reason: optimization ...

  3. #3
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    194

    Re: VBB Code to Trim Check number from Text

    Hello Marc
    Not sure why it is not working
    Attached is the pic of the situation, please modifi the code to fix the issue

    Thanks
    Attached Images Attached Images

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBB Code to Trim Check number from Text


    As my VBA demonstration well works with your attachment !
    It's what happens with poor attachment, so weird to not attach a workbook well reflecting the original …

    My Excel can't work obviously from a picture so just check the cells contents.
    Last edited by Marc L; 11-06-2022 at 02:01 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBB Code to Trim Check number from Text

    Hello. Another approach to the problem:

    PHP Code: 
    Sub Macro1()
    With Range("e2"Cells(Rows.Count5).End(xlUp))
      .
    Offset(, -1) = Evaluate("IfError(0 + Right(" & .Address ", 6), """")")
    End With
    End Sub 

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VBB Code to Trim Check number from Text

    Hello

    I am sorry Marc.
    Attached is the actual file
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Re: VBB Code to Trim Check number from Text


    As on my side my VBA demonstration well works with your last attachment for row #139
    so check if you have the same post #2 code or erase and copy / paste again …

    But according to this last attachment you should obviously better ask for Check # :

    PHP Code: 
    Sub Demo2()
            
    Dim VR&
        
    With Sheet1.Range("D2:D" Sheet1.[A1].CurrentRegion.Rows.Count)
            
    = .Columns(2).Value
        
    For 1 To UBound(V)
            If 
    V(R1Like "Check #*" Then V(R1) = Val(Mid(V(R1), 7)) Else V(R1) = Empty
        
    Next
           
    .Value V
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 11-06-2022 at 02:39 PM.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,211

    Re: VBB Code to Trim Check number from Text

    Try

    in D2

    =IF(ISNUMBER(SEARCH("Check",E2)),TRIM(SUBSTITUTE(E2,"Check","")),"")
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Or this ...


    According to your last attachment the direct Excel formula way VBA demonstration :

    PHP Code: 
    Sub Demo2f()
        
    With Sheet1.Range("D2:D" Sheet1.[A1].CurrentRegion.Rows.Count)
            .
    Value = .Parent.Evaluate(Replace("IF(LEFT(#,6)=""Check "",RIGHT(#,LEN(#)-6),"""")""#", .Columns(2).Address))
        
    End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  10. #10
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VBB Code to Trim Check number from Text

    Hello Marc

    Thanks a lot

    R

+ 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] how to check a cell value having text length 10 which is combination of text and number
    By amitnigamz in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-08-2020, 03:04 PM
  2. [SOLVED] Remove blank space in front of text to turn into a number. Trim, Substitute will not work.
    By jaboomgaarden in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-15-2018, 05:59 PM
  3. Replies: 10
    Last Post: 07-22-2018, 04:00 PM
  4. [SOLVED] Improving text to column code to use a TRIM to cleanup further the results
    By PaulM100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2018, 03:15 AM
  5. I need a code for presence check to check multiple text boxes and combo boxes
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2013, 01:53 PM
  6. [SOLVED] Trim text after any number 0 through 9?
    By GHawsJR in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-23-2012, 11:26 AM
  7. [SOLVED] Check if cellvalue is text or number, even when number is in textformat
    By MarMo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-22-2012, 07:53 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