Murray Brown

asked on

# Excel VBA find the 4th instance of a word

Hi

What Excel VBA code would use to find the 4th instance of the word "CLOSING" using the FIND function and return the row address?

The instance changes so I need to sometimes find the 5th or 6th instance.

Thanks

What Excel VBA code would use to find the 4th instance of the word "CLOSING" using the FIND function and return the row address?

The instance changes so I need to sometimes find the 5th or 6th instance.

Thanks

do you have the sample words?

Also providing the excel will be helpful

And maybe you want to find the last instance ?

ASKER CERTIFIED SOLUTION

membership

Create an account to see this answer

Signing up is free. No credit card required.

Here is the Excel version:

Find nth occurrence (position) of a character in a Cell with Find formula

In a blank cell, enter the formula =FIND("c",A1,FIND("c",A1)+2).

And then press the Enter key. ...

Note: You can change the 2 in the formula based on your needs.

https://www.extendoffice.com/documents/excel/1052-excel-find-nth-occurrence.html#a1

Find nth occurrence (position) of a character in a Cell with Find formula

In a blank cell, enter the formula =FIND("c",A1,FIND("c",A1)+

And then press the Enter key. ...

Note: You can change the 2 in the formula based on your needs.

https://www.extendoffice.com/documents/excel/1052-excel-find-nth-occurrence.html#a1

This is the code in one line

```
cells.Find("computer",cells.Find("computer",cells.Find("computer",cells.Find("computer",,,xlpart),,xlpart),,xlpart),,xlpart).Row
```

You can make it more readable like this ```
Cells.Find("computer", _
Cells.Find("computer", _
Cells.Find("computer", _
Cells.Find("computer", , , xlPart) _
, , xlPart) _
, , xlPart) _
, , xlPart).Row
```

ASKER

Thanks very much