Results 1 to 5 of 5
  1. #1
    PasJes is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2023
    Posts
    6

    Remove a string between 2 characters

    I have a field (badge) in a table that contains a bunch of data that I don't require in the field.


    eg

    Super Charger (291N) Quad System
    Super Charger (1NMBCFL) Quad
    GTA (937.AXL1) Axpro
    JTDM (937.AXN1B, 937.BXN1B) Trident

    So the information between the parentheses (and the parentheses themselves) are not required...

    Ideally the data above should look like:

    Super Charger Quad System
    Super Charger Quad
    GTA Axpro
    JTDM Trident

    Is there any way to do this? I have about 20,000 records so doing this manually would be problematic!

    Thanks in advance.

  2. #2
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    Sure there is a way. Invest some time in learning about the Mid and Instr function.

    https://support.microsoft.com/en-us/...8-77cd0cb8a55b
    https://support.microsoft.com/en-au/...1-5ecf4421eb8a
    Groeten,

    Peter

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    PasJes,

    You may get some insight and/or examples from the Similar Threads at the bottom of this page.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I'm thinking these functions
    - Instr
    - InstrRev
    - Mid
    - Replace
    However this type of task is often solved with less coding using vba and RegEx - just don't ask me how to do it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Actually it's not that bad - six lines of code. Since we're all posting code solutions at one time or another, I don't see why not this time. It might help someone else in the future even if the OP doesn't come back. While it works, it probably needs additional code in order to make it work with some other process such as a form, report or update query.
    Code:
    Function ParensText(strIn As String) As String
    Dim intPos1 As Integer, intpos2 As Integer
    
    intPos1 = InStr(strIn, "(")
    intpos2 = InStrRev(strIn, ")")
    ParensText = Replace(strIn, Mid(strIn, intPos1, intpos2 - intPos1 + 2), "")
    Debug.Print ParensText
    
    End Function
    called like
    parenstext "JTDM (937.AXN1B, 937.BXN1B) Trident"
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to remove last characters of a string?
    By MsAxes in forum Modules
    Replies: 3
    Last Post: 03-20-2023, 10:15 AM
  2. Replies: 7
    Last Post: 04-14-2015, 03:26 PM
  3. Replies: 3
    Last Post: 07-28-2014, 06:03 PM
  4. Replies: 5
    Last Post: 06-28-2012, 10:49 AM
  5. Replies: 5
    Last Post: 03-10-2011, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums