ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   select cells (https://www.excelbanter.com/excel-discussion-misc-queries/245838-select-cells.html)

puiuluipui

select cells
 
Hi, how can i select with a macro all cells with data below activecell?
Thanks!

Rick Rothstein

select cells
 
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

--
Rick (MVP - Excel)


"puiuluipui" wrote in message
...
Hi, how can i select with a macro all cells with data below activecell?
Thanks!



Gary''s Student

select cells
 
In any column or only the activecell's column??
--
Gary''s Student - gsnu200908


"puiuluipui" wrote:

Hi, how can i select with a macro all cells with data below activecell?
Thanks!


Gary''s Student

select cells
 
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

--
Gary''s Student - gsnu200908


"puiuluipui" wrote:

Hi, how can i select with a macro all cells with data below activecell?
Thanks!



All times are GMT +1. The time now is 07:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com