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 8939307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:47:51+00:00 2026-06-15T10:47:51+00:00

In a VB macro for Excel, how do I remove all occurances of a

  • 0

In a VB macro for Excel, how do I remove all occurances of a word that starts with a certain string?

Eg:

The string reads: xxxx $AUD543.43 yyyy

I want to search for anything in a string that starts with $AUD and remove the whole word before the next space

So the example above should result in:

xxxx yyyy

  • 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-06-15T10:47:52+00:00Added an answer on June 15, 2026 at 10:47 am

    It would be remiss of me not to remind you of the expectation that you show “what you (have) tried”. (Which I do to avoid me being yelled at for answering the question.) My duty thus having been done, I now move on to it.

    You actually don’t necessarily need VBA code to do this; you could do it with the Find() function albeit more clumsily and I wouldn’t recommend it for a really large sheet. Still, VBA code you have specified, and that you shall have. Change the range to match the one that you’ll be searching. ALSO, you should note that you have only one space between the x’s and y’s in your example but that varies from your request that it be the word starting with $AUD and ending BEFORE the next space. If you want only one space, please adjust the formulas accordingly.

    Sub ReplaceText()
    
    Dim rng As Excel.Range
    Dim s_Contents As String
    Dim l_FindAUD As Long, l_FindSpace As Long
    
    For Each rng In ActiveSheet.UsedRange
    
        s_Contents = rng.Value
    
        'Does the $AUD expression exist in this cell?
        l_FindAUD = InStr(1, s_Contents, "$AUD", vbTextCompare)
    
        If l_FindAUD > 0 Then
    
            'If so, is it followed by a space?
            l_FindSpace = InStr(l_FindAUD, s_Contents, " ")
    
            If l_FindSpace > 0 Then
    
                'If so, take all of the content up to but not including the $
                'and all of the contents from the space onwards, merge them
                'together and write to the cell.
                s_Contents = Left$(s_Contents, l_FindAUD - 1) & Mid$(s_Contents, l_FindSpace)
                rng.Value = s_Contents
            End If
    
        End If
    
    Next
    
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm coding a macro for word and excel. The output are generated files that
I have an Excel macro that is copying all of the information from a
I'm running an Excel macro that calls a LISP script, which has always worked
I have created a macro for excel which will pop up form that contains
I want to implement some code in excel macro to group some data for
I want to connect to DB2 from excel macro...This is my code, but it
Trying to run a macro in Excel to remove non dupes so dupes can
We were trying to Sign an Excel Macro, but got an error that it
I would like to write a macro in Excel that will write to a
I have a macro that add hundreds of lines of data to an excel

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.