Question: I have a table that have logins in one column and phone numbers in another. I need to copy all phone numbers of each login and paste them to another sheet. But i need only unique phone numbers as one login may contain many records with the same phone number. What i have tried and what failed

```
For Each rCell In Sheets("PotentialFraud").Range("B1:B" & IndexValueLastRow("B:B"))
    .Range("A2").AutoFilter _
    field:=12, _
    Criteria1:=rCell.Value2
    LastRow = .Cells(1, 1).SpecialCells(xlCellTypeVisible).End(xlDown).Row
    .Range("P1:P" & LastRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).Copy
    Worksheets("PotentialFraud").Range(rCell.Offset(0, 2).Address).PasteSpecial Transpose:=True
Next rCell

```

This Method does not give me an option to copy only unique values.
Another option I found was to use Advanced Filter

```
   .Range("P2:P" & LastRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).AdvancedFilter _
        Action:=xlFilterCopy, _
        CopyToRange:=Worksheets("PotentialFraud").Range("A:A"), _
        Unique:=True

```

However, this lead to error 1004 saying either **This command requires at least two rows of source data...** even though there are 2500 rows visible. Either **Application-defined or object-defined error** if i change the range to

```
    .Range("P:P" & LastRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Worksheets("PotentialFraud").Range("A:A"), _
Unique:=True

```

*("P2:P") to ("P:P")*

Answer: 
you can add this

```
onFocus={useTheOnFocus ? onFocusHandler : undefined}

```

or set a handler

```
onFocus={onFocusHandler}

```

and check a condition in a handler

```
onFocusHandler = (ev) => {
   if(!condition) {
      return null;
   }
   // your code
}

```
You can give event handlers a value of `undefined` if you don't want them to be active.

**Example**

```js
class App extends React.Component {
  state = { useTheOnFocus: false };

  componentDidMount() {
    setInterval(() => {
      this.setState(prevState => ({
        useTheOnFocus: !prevState.useTheOnFocus
      }));
    }, 2000);
  }

  onFocusHandler = evt => {
    evt.preventDefault();
    console.log("Focus handler active");
  };

  render() {
    const { useTheOnFocus } = this.state;

    return (
      <input
        type="text"
        className="some-class"
        onFocus={useTheOnFocus ? this.onFocusHandler : undefined}
      />
    );
  }
}

ReactDOM.render(<App />, document.getElementById("root"));
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

<div id="root"></div>
```