Question: Heya this is probably simple but I cannot figure out what is wrong.

I am trying to do .find for a specific date and change that selection to a user input date.

I have a userform to select a date from a combobox (date1\_cbo). The combobox source is linked to dates on a worksheet (Backend). There is a textbox below for writing the new date to change it to (date1\_txt). I keep getting an error 

> 
> object variable or with block variable not set. 
> 
> 
> 

I have tried a few options without any luck here is my code:

```
Dim selection As Range
Dim check As Boolean

'input box validation
check = IsDate(date1_txt.Value)
If check = True Then
    'find cell matching combobox
    With Worksheets("Backend").Range("A1:A500")
        Set selection = .Find(date1_cbo.Value) 'this is the problem
        selection.Value = date1_txt.Value
    End With
Else
End If

```

Interestingly .Find returns the range or Nothing. however because the combobox is linked to the cells I am searching through this should never return nothing... I dont understand why the error is occurring.

Answer: 
a variable named as 'selection' is bad coding practice but totally legal. Don't use such names for the sake of clarity.

---

Error 91 is caused when you are trying to read a property( `.value`) from null object. your selection variable is null cause date formats on the sheet and combobox are different. 

---

Just convert to date before attempting to find it in sheet. 
`Set selection = .Find(CDate(date1_cbo.Value)) '/ once again, selection is valid but bad name for variable.`
You are using a variable named `Selection`. VBA uses it as well. Rename your variable to anything else, rewrite your code and it should work. Even `Selection1` is quite ok:

```
Public Sub TestMe()

    Dim selection1 As Range
    With Worksheets(1).Range("A1:A500")
        Set selection1 = .Find("vi")
    End With

    If Not selection Is Nothing Then
        selection1.Value = "some other value"
    End If

End Sub

```

---

To change multiple values with `Find()` as here - `A1:A10`, then some possibility is to do it like this:

```
Public Sub TestMe()

    Dim myRng As Range

    With Worksheets(1).Range("A1:A500")
        .Range("A1:A10") = "vi"
        Set myRng = .Find("vi")
        If Not myRng Is Nothing Then
            Do Until myRng Is Nothing
                myRng.Value = "New value"
                Set myRng = .Find("vi")
            Loop
        End If
    End With

End Sub

```

It is a bit slow, as far as it loops every time and it can be improved, if the range is united and replaced at once.