ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Use xldown to select a range of cells (https://www.excelbanter.com/excel-discussion-misc-queries/231965-use-xldown-select-range-cells.html)

merry_fay

Use xldown to select a range of cells
 
Hiya,

When I run the macro using this code:

Range("A4:R4").Select
Selection.End(xlDown).Activate
Selection.Copy

Only the bottom left cell is being selected. I need the whole range to be
selected.
Can anyone help please?

Thanks
merry_fay

Eduardo

Use xldown to select a range of cells
 
Hi ,
if you always want to select A4 to R4 just use
Range("A4:R4").Select

"merry_fay" wrote:

Hiya,

When I run the macro using this code:

Range("A4:R4").Select
Selection.End(xlDown).Activate
Selection.Copy

Only the bottom left cell is being selected. I need the whole range to be
selected.
Can anyone help please?

Thanks
merry_fay


Eduardo

Use xldown to select a range of cells
 
OPPs
, I sent the message before finishing

if you want to select from A4 up to the last row used in R

Sub Macro1()
'
' Macro1 Macro
'

Dim myrange, MyRange1 As Range
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Sheets("Sheet1").Range("A4:R" & lastRow)
myrange.Copy
End Sub

if this helps please click yes, thanks

"Eduardo" wrote:

Hi ,
if you always want to select A4 to R4 just use
Range("A4:R4").Select

"merry_fay" wrote:

Hiya,

When I run the macro using this code:

Range("A4:R4").Select
Selection.End(xlDown).Activate
Selection.Copy

Only the bottom left cell is being selected. I need the whole range to be
selected.
Can anyone help please?

Thanks
merry_fay


Jim Thomlinson

Use xldown to select a range of cells
 
Generally speaking you are better to use xlup from the bottom (which stops at
the last complete cell of the worksheet) than xldown (which stops at the
first blank).

in either case you don't need to select

Range(Range("A4"), Cells(Rows.Count, "A").End(xlUp)).Copy
'or
Range(Range("A4"), Range("A4").End(xlDown)).Copy

--
HTH...

Jim Thomlinson


"merry_fay" wrote:

Hiya,

When I run the macro using this code:

Range("A4:R4").Select
Selection.End(xlDown).Activate
Selection.Copy

Only the bottom left cell is being selected. I need the whole range to be
selected.
Can anyone help please?

Thanks
merry_fay



All times are GMT +1. The time now is 06:08 AM.

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