FInding Match in more than 1 cell

ManUBlueJay

Active Member
Joined
Aug 30, 2012
Messages
272
Office Version
  1. 2016
Platform
  1. Windows
I need to find a given text in a cell in "myRange" and change the value 2 cells over. The first one is easy using Offset and match. Does any one have any Idea how to find the others. A little VBA script would also be fine as I would run it from a macro anyway.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
50,606
Office Version
  1. 365
Platform
  1. Windows
It isn't clear whether "myRange" is a named range or a vba variable. I have assumed the latter.
You could try something like this

Rich (BB code):
Dim rFound As Range
Dim firstAddress As String

Set rFound = myRange.Find(What:="abc", LookIn:=xlValues, LookAt:=xlWhole)
If Not rFound Is Nothing Then
  firstAddress = rFound.Address
  Do
    rFound.Offset(, 2).Value = "new value" 'or whatever you want to with that cell 2 over
    Set rFound = myRange.FindNext(After:=rFound)
  Loop While rFound.Address <> firstAddress
End If

If "myRange" is actually a named range then change each myRange in the above code to Range("myRange")
 

ManUBlueJay

Active Member
Joined
Aug 30, 2012
Messages
272
Office Version
  1. 2016
Platform
  1. Windows
Thank You. Unfortunately "MY Range is a Named Range. Could you help me with that?
Thanks
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
50,606
Office Version
  1. 365
Platform
  1. Windows
Thank You. Unfortunately "MY Range is a Named Range. Could you help me with that?
Thanks
I thought I already did. Did you read the text in my last post under the code box?
 
Last edited:

Forum statistics

Threads
1,141,315
Messages
5,705,699
Members
421,406
Latest member
kluna90

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top