select cells

  • Thread starter Thread starter puiuluipui
  • Start date Start date
P

puiuluipui

Hi, how can i select with a macro all cells with data below activecell?
Thanks!
 
This macro should do what you want...

Sub SelectNonEmptyCellsBelowActiveCell()
Dim LastCell As Range
On Error Resume Next
Set LastCell = Cells(Rows.Count, ActiveCell.Column).End(xlUp)
Range(ActiveCell.Offset(1), LastCell).SpecialCells( _
xlCellTypeConstants).Select
End Sub
 
To select cells below the active cell with data in them:

Sub WithData()
Set r = Range(ActiveCell.Offset(1, 0), Cells(Rows.Count, ActiveCell.Column))
Set r = Intersect(r, ActiveSheet.UsedRange)
Set rSelect = Nothing
For Each rr In r
If IsEmpty(rr) Then
Else
If rSelect Is Nothing Then
Set rSelect = rr
Else
Set rSelect = Union(rSelect, rr)
End If
End If
Next
rSelect.Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top