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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:53:57+00:00 2026-05-27T19:53:57+00:00

In Excel I am trying to use Find and Replace on some data to

  • 0

In Excel I am trying to use Find and Replace on some data to remove everything after a double space. An example of this data is…

The Apples are Green  They are supplied by John
The Bannanas are Yellow  They are supplied by Tom
The Strawberries are Red  They are supplied by Jason

I want the data to look like this…

The Apples are Green
The Bannanas are Yellow
The Strawberries are Red

In Openoffice I can search for ‘ .*’ and replace it with nothing and this works, but with Excel it doesnt.

I do eventually want to work this into a macro but for now I am just trying to get it to work with Find and Replace, can anyone help?

  • 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-27T19:53:58+00:00Added an answer on May 27, 2026 at 7:53 pm

    Here’s an alternative way of doing what you are trying to accomplish. I find it gives you more control than Find and Replace.

    ' Get the contents of the cell
    Dim s As String
    s = Range("A1").Value
    ' Now write back only what precedes the double space
    Range("A1").Value = Left(s, InStr(s, "  ") - 1)
    

    The above operates on only one cell. To do the same over many cells, you could do this:

    Dim cell As Range
    For Each cell In Range("A1:A3")
        cell.Value = Left(cell.Value, InStr(cell.Value, "  ") - 1)
    Next cell
    

    As has been pointed out in other answers, you should replace any troublesome non-break spaces (Chr(160)) by regular spaces, prior to searching for double spaces:

    Dim cell As Range
    For Each cell In Range("A1:A3")
        cell.Value = Left(cell.Value, _
            InStr(Replace(cell.Value, Chr(160), " "), "  ") - 1)
    Next cell
    

    EDIT Addressing @chris neilsen’s comment:

    If some of your target cells are devoid of double spaces, then you should check for that prior to using the Left function lest it raise an error:

    Dim cell As Range
    Dim i As Long
    For Each cell In Range("A1:A5")
        i = InStr(Replace(cell.Value, Chr(160), " "), "  ")
        If i > 0 Then
            cell.Value = Left(cell.Value, i - 1)
        End If
    Next cell
    

    Now, on the very remote chance that some of the target cells contain formulas comprising double spaces (e.g. =A1 & "<space><space>" & A2), these formulas will be replaced by values. To avoid this, change the conditional to If i > 0 And Not cell.HasFormula Then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the following code to write data into an excel
I was trying to output Excel's data to a text file to use them
I am trying to use Excel the DateAdd function to find the next working
I am trying to use an excel file that has data such as first
In .NET C# I'm trying to open an Excel template, add some data and
I am trying to find out the right if statement to use for this
I'm trying to use a post form to generate an excel file after choosing
I'm trying to use ADODB in VBScript to access an Excel file to find
I need to save some data in .xls file. I am trying to use
I am trying to use ShellExecute to open a file in Excel. I was

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.