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

```
> 
> 
> ```
> If Range("N6:N125") = "" Then
> 
> ```
> 
> 

This doesn't do the job. You will need to do this test cell-by-cell. An easier alternative would be this:

```
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  On Error Resume Next
  Range("N6:N125").SpecialCells(xlCellTypeBlanks).value = "My Text"
End Sub

```

This will fill empty cells within the range. BUT, if the intent of your test is to check whether the whole range is empty, this:

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

```