Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Find and Replace 2 cells

Hi, I know that using find (ctrl+f) you can choose a certain value in a cell
and replace it. I was wondering if you could do this for 2 or more cells. For
example, can you tell excel to search for all instances in which a cell in
collumn B has a certain value (for example x) and the cell to the right of it
has another certain value (for example y) so that every time a cell in
collumn B has a value of x and the cell to the right of it (in collumn c) has
a value of Y, excel will replace Y with another value (for example z).
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default Find and Replace 2 cells

Without VBA, I'd probably do this with autofilter. Select the value for B
that you want and the value for C that you want and change as needed.


"NOOBY92" wrote:

Hi, I know that using find (ctrl+f) you can choose a certain value in a cell
and replace it. I was wondering if you could do this for 2 or more cells. For
example, can you tell excel to search for all instances in which a cell in
collumn B has a certain value (for example x) and the cell to the right of it
has another certain value (for example y) so that every time a cell in
collumn B has a value of x and the cell to the right of it (in collumn c) has
a value of Y, excel will replace Y with another value (for example z).

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Find and Replace 2 cells

What about with vba. Autofilter doesn't automatically change the values. If I
have over 500 values then that solution won't work.

"Barb Reinhardt" wrote:

Without VBA, I'd probably do this with autofilter. Select the value for B
that you want and the value for C that you want and change as needed.


"NOOBY92" wrote:

Hi, I know that using find (ctrl+f) you can choose a certain value in a cell
and replace it. I was wondering if you could do this for 2 or more cells. For
example, can you tell excel to search for all instances in which a cell in
collumn B has a certain value (for example x) and the cell to the right of it
has another certain value (for example y) so that every time a cell in
collumn B has a value of x and the cell to the right of it (in collumn c) has
a value of Y, excel will replace Y with another value (for example z).

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default Find and Replace 2 cells

Try this:

Sub Test()
Dim myRange As Range, r As Range
Dim lastRow As Long
Dim aWS As Worksheet

Set aWS = ActiveSheet

lastRow = aws.Cells(Rows.Count, 2).End(xlUp).Row
Debug.Print lastRow

Set myRange = aws.Cells(1, 2).Resize(lastRow, 1)
myRange.Select

For Each r In myRange
If LCase(r.Value) = "x" Then
If LCase(r.Offset(0, 1).Value) = "y" Then
Debug.Print r.Row, r.Column, r.Value, r.Offset(0, 1).Value
r.Offset(0, 1).Value = "z"
End If
End If
Next r

End Sub

"NOOBY92" wrote:

What about with vba. Autofilter doesn't automatically change the values. If I
have over 500 values then that solution won't work.

"Barb Reinhardt" wrote:

Without VBA, I'd probably do this with autofilter. Select the value for B
that you want and the value for C that you want and change as needed.


"NOOBY92" wrote:

Hi, I know that using find (ctrl+f) you can choose a certain value in a cell
and replace it. I was wondering if you could do this for 2 or more cells. For
example, can you tell excel to search for all instances in which a cell in
collumn B has a certain value (for example x) and the cell to the right of it
has another certain value (for example y) so that every time a cell in
collumn B has a value of x and the cell to the right of it (in collumn c) has
a value of Y, excel will replace Y with another value (for example z).

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Find and Replace 2 cells

I am kind of a noob with vba so could you explain where to put in all
information (ex. name of variable, name of collumn, new variable etc)

"Barb Reinhardt" wrote:

Try this:

Sub Test()
Dim myRange As Range, r As Range
Dim lastRow As Long
Dim aWS As Worksheet

Set aWS = ActiveSheet

lastRow = aws.Cells(Rows.Count, 2).End(xlUp).Row
Debug.Print lastRow

Set myRange = aws.Cells(1, 2).Resize(lastRow, 1)
myRange.Select

For Each r In myRange
If LCase(r.Value) = "x" Then
If LCase(r.Offset(0, 1).Value) = "y" Then
Debug.Print r.Row, r.Column, r.Value, r.Offset(0, 1).Value
r.Offset(0, 1).Value = "z"
End If
End If
Next r

End Sub

"NOOBY92" wrote:

What about with vba. Autofilter doesn't automatically change the values. If I
have over 500 values then that solution won't work.

"Barb Reinhardt" wrote:

Without VBA, I'd probably do this with autofilter. Select the value for B
that you want and the value for C that you want and change as needed.


"NOOBY92" wrote:

Hi, I know that using find (ctrl+f) you can choose a certain value in a cell
and replace it. I was wondering if you could do this for 2 or more cells. For
example, can you tell excel to search for all instances in which a cell in
collumn B has a certain value (for example x) and the cell to the right of it
has another certain value (for example y) so that every time a cell in
collumn B has a value of x and the cell to the right of it (in collumn c) has
a value of Y, excel will replace Y with another value (for example z).

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find multiple cells/replace whole cells w/data dcurylo Excel Discussion (Misc queries) 2 November 30th 05 08:06 PM
Find & Replace within Unlocked Cells in a Protected Worksheet DaveyC4S Excel Discussion (Misc queries) 2 October 9th 05 11:12 AM
find and replace path name in Excel cells containing hyperlink leoe Excel Discussion (Misc queries) 1 August 9th 05 08:57 PM
Excel-how (find/replace) for multifmat cells w/o changing fmat Joe Schiano Excel Discussion (Misc queries) 2 June 23rd 05 01:06 AM
Find/Replace Text In Cells Rob Excel Discussion (Misc queries) 1 April 11th 05 04:01 AM


All times are GMT +1. The time now is 11:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"