1. Your sample data is in column A. Therefore, the line:
ActiveCell.Offset(0, -1)
is trying to look one column to the left of column A. ---> Error
2. The InStr function returns the position of one string within another, so the line:
ActiveCell.Value = InStr(ActiveCell.Offset(0, -1).Value, "Mr & Mrs")
would, if not for the previous error, have replaced the contents of the active cell with a 1 since Mr & Mrs is at the beginning of the string. Offset jumps other cells at a given distance from the achor cell, not to positions within strings in a cell.
Unfortunately, you have other errors...
For instance, you have:- Find(" ", b3, 1) which is a worksheet function, not a VBA function. You need to use Instr, but you have to specify where in the string to start.
- Some cells have "&", others "and" and others neither.
- ActiveCell.Value = "Mr" & ActiveCell.Offset(0, 2) is trying to replace the contents of the active cell with "Mr" and contents of the cell 2 columns to the right, i.e. column C
Bookmarks