ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selecting a non-empty range of cells (https://www.excelbanter.com/excel-programming/314329-selecting-non-empty-range-cells.html)

Mourinho

selecting a non-empty range of cells
 

The very useful short-cut keystroke CTRL-SHIFT and DOWN/UP selects a range
of cells with data in it. How can this action be repeated in a macro?
(Record_Macro returns the absolute range).

I need to return a cell count to manipulate data associated with this
selected range.

Thanks

Starwing

selecting a non-empty range of cells
 
Hi!

Sub SelectionUp()
Range(ActiveCell, ActiveCell.End(xlUp)).Select
End Sub


Sub SelectionDown()
Range(ActiveCell, ActiveCell.End(xlDown)).Select
End Sub

Starwing




"Mourinho" a écrit dans le message de
...

The very useful short-cut keystroke CTRL-SHIFT and DOWN/UP selects a range
of cells with data in it. How can this action be repeated in a macro?
(Record_Macro returns the absolute range).

I need to return a cell count to manipulate data associated with this
selected range.

Thanks




Mourinho

selecting a non-empty range of cells
 
Thanks

Though am getting an error when attempting this..xlRight
Is this an incorrect method? (see below)

M

Sub CountMonth()
' Returns Run Length and No.of Columns in RSM file
Dim CntMon
Dim CntRsm

ActiveSheet.Range("B7").Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
CntMon = Selection.Count
ERROR Range(ActiveCell, ActiveCell.End(xlRight)).Select ERROR
CntRsm = Selection.Count
End Sub

"Starwing" wrote:

Hi!

Sub SelectionUp()
Range(ActiveCell, ActiveCell.End(xlUp)).Select
End Sub


Sub SelectionDown()
Range(ActiveCell, ActiveCell.End(xlDown)).Select
End Sub

Starwing




"Mourinho" a écrit dans le message de
...

The very useful short-cut keystroke CTRL-SHIFT and DOWN/UP selects a range
of cells with data in it. How can this action be repeated in a macro?
(Record_Macro returns the absolute range).

I need to return a cell count to manipulate data associated with this
selected range.

Thanks





Jorge Rodrigues

selecting a non-empty range of cells
 
Mourinho,
Not xlRight, but xlToRight, xlToLeft,xlUp,xlDown.
Jorge
"Mourinho" escreveu na mensagem
...
Thanks

Though am getting an error when attempting this..xlRight
Is this an incorrect method? (see below)

M

Sub CountMonth()
' Returns Run Length and No.of Columns in RSM file
Dim CntMon
Dim CntRsm

ActiveSheet.Range("B7").Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
CntMon = Selection.Count
ERROR Range(ActiveCell, ActiveCell.End(xlRight)).Select ERROR
CntRsm = Selection.Count
End Sub

"Starwing" wrote:

Hi!

Sub SelectionUp()
Range(ActiveCell, ActiveCell.End(xlUp)).Select
End Sub


Sub SelectionDown()
Range(ActiveCell, ActiveCell.End(xlDown)).Select
End Sub

Starwing




"Mourinho" a écrit dans le message

de
...

The very useful short-cut keystroke CTRL-SHIFT and DOWN/UP selects a

range
of cells with data in it. How can this action be repeated in a macro?
(Record_Macro returns the absolute range).

I need to return a cell count to manipulate data associated with this
selected range.

Thanks








All times are GMT +1. The time now is 10:22 AM.

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