Question: My question is very similar to the following:

[Excel VBA code to select non empty cells](https://stackoverflow.com/questions/39967118/excel-vba-code-to-select-non-empty-cells/39967976#39967976)
However, I have some empty cells in between. In particular, I'm trying to define a range where the first row needs to be excluded, since it's a header. I also have to exclude the empty cells that follow. I was trying something like

```
Dim wb as workbook, ws as worksheet
Dim myrange as range

'Defined reference wb and ws
myrange=ws.range("B2",range("B2"),end(xldown))

```

But this only works if there are not empty cells in between. So, is there a fast and simple way to dynamically select a range that includes non-empty cells, excepted the header?

Answer: 
Try this

```vb
'Defined reference wb and ws
Set myrange = ws.range("B2", ws.Range("B" & Rows.Count).End(xlUp))

```

Don't forget to use the `Set` keyword
Try the next way, please:

```
Sub testDefineRange()
 Dim ws As Worksheet, lastRow As Long, myrange As Range

 Set ws = ActiveSheet 'use here what you need
 lastRow = ws.Range("B" & ws.rows.count).End(xlUp).row
 'Defined reference ws
 Set myrange = ws.Range("B2:B" & lastRow)
 myrange.Select
End Sub

```