ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Find & Replace: find part cell, replace whole cell (https://www.excelbanter.com/excel-worksheet-functions/191639-find-replace-find-part-cell-replace-whole-cell.html)

Katy

Find & Replace: find part cell, replace whole cell
 
I would like to be able to do a Find & Replace where I find any cell which
contains a certain text string within the cell contents, and replaces the
WHOLE CELL with another text string. Anyone know of a simple way to do this?

Specifically, I have a large number of cells with contents like
01/06/2008 - 30/06/2008
The first date is always the same but the second date can be any one of
hundreds of dates. I want to find all cells which start "01/06/2008" and
replace the whole cell with "2008-09". It seems that if I do a Find &
Replace (ctrl-H) without 'match entire cell contents' selected, then only the
first part of the cell is replaced and the second date remains (not what I
want), but to get a 'match entire cell contents' to work, I would have to do
a separate Find & Replace for every possible original value of the cell
(hundreds of possibilities).

I'm not great with VBA, but I tried recording a macro while I did the Find &
Replace, to see if I could then amend the code to make it work, but it didn't
look easy to do it this way so I think I need an entirely new bit of code!
Any ideas...?

Thanks
Katy

ExcelBanter AI

Answer: Find & Replace: find part cell, replace whole cell
 
Hi Katy,

Yes, there is a way to do a Find & Replace where you can find any cell which contains a certain text string within the cell contents, and replace the WHOLE CELL with another text string. Here's how you can do it:
  1. Select the range of cells that you want to search and replace.
  2. Press Ctrl + H to open the Find and Replace dialog box.
  3. In the "Find what" field, enter the text string that you want to find (in your case,
    Code:

    "01/06/2008*"
    ).
  4. In the "Replace with" field, enter the text string that you want to replace the whole cell with (in your case, "2008-09").
  5. Click on the "Options" button to expand the dialog box.
  6. Check the "Match entire cell contents" box.
  7. Click on the "Replace All" button.

This should replace all cells that start with "01/06/2008" with "2008-09". The asterisk (*) in the "Find what" field is a wildcard character that tells Excel to find any text string that starts with "01/06/2008".

Katy

Find & Replace: find part cell, replace whole cell
 
D'oh - all I needed was a wildcard (*):
Find "01/06/2008*" and replace with "2008-09"
Apologies for wasting people's time! : )

"katy" wrote:

I would like to be able to do a Find & Replace where I find any cell which
contains a certain text string within the cell contents, and replaces the
WHOLE CELL with another text string. Anyone know of a simple way to do this?

Specifically, I have a large number of cells with contents like
01/06/2008 - 30/06/2008
The first date is always the same but the second date can be any one of
hundreds of dates. I want to find all cells which start "01/06/2008" and
replace the whole cell with "2008-09". It seems that if I do a Find &
Replace (ctrl-H) without 'match entire cell contents' selected, then only the
first part of the cell is replaced and the second date remains (not what I
want), but to get a 'match entire cell contents' to work, I would have to do
a separate Find & Replace for every possible original value of the cell
(hundreds of possibilities).

I'm not great with VBA, but I tried recording a macro while I did the Find &
Replace, to see if I could then amend the code to make it work, but it didn't
look easy to do it this way so I think I need an entirely new bit of code!
Any ideas...?

Thanks
Katy


radicaltp

Find & Replace: find part cell, replace whole cell
 
beautiful . love u katy:)

"katy" wrote:

D'oh - all I needed was a wildcard (*):
Find "01/06/2008*" and replace with "2008-09"
Apologies for wasting people's time! : )

"katy" wrote:

I would like to be able to do a Find & Replace where I find any cell which
contains a certain text string within the cell contents, and replaces the
WHOLE CELL with another text string. Anyone know of a simple way to do this?

Specifically, I have a large number of cells with contents like
01/06/2008 - 30/06/2008
The first date is always the same but the second date can be any one of
hundreds of dates. I want to find all cells which start "01/06/2008" and
replace the whole cell with "2008-09". It seems that if I do a Find &
Replace (ctrl-H) without 'match entire cell contents' selected, then only the
first part of the cell is replaced and the second date remains (not what I
want), but to get a 'match entire cell contents' to work, I would have to do
a separate Find & Replace for every possible original value of the cell
(hundreds of possibilities).

I'm not great with VBA, but I tried recording a macro while I did the Find &
Replace, to see if I could then amend the code to make it work, but it didn't
look easy to do it this way so I think I need an entirely new bit of code!
Any ideas...?

Thanks
Katy



All times are GMT +1. The time now is 04:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com