Question: I am trying to autofill text in a range(N6:N125) in excel 2013 via vba. My code works fine when range refers a single cell but not for a range. could you help me to find my mistake? My code is 

```
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("N6:N125") = "" Then
Range("N6:N125").value = "My Text"
End If
End Sub

```

Answer: 
If you want to fill only the empty cells in **N6** through **N125** and some of the cells may already have values, but none have formulas, then a loop is not actually needed:

```
Sub marine()
    Dim r As Range, s As String
    Set r = Range("N6:N125")
    s = "=IF(N6:N125="""",""MyText"",N6:N125)"
    r.Value = Evaluate(s)
End Sub

```
You can use: 

```
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

With Selection

For Each cell In Selection

If cell = "" Then
cell.Value = "My Text"
End If
Next cell
End With
End Sub 

```

This code will test each cell in your selection if empty and write "My Text" in it, but if it is not empty it will skip it. 

In your code you are not testing each cell and you are not using a loop to move from one cell to another